< Back to IRCAM Forum

Calling External Scripts

Hi, is there any way to call an external script (e.g. bash, python) and to obtain the stdout stream? OM-SHELL only gives me the return value. For example, if I call a script which prints out “1 2 3”, I can see it in the Listener followed by the return value (0).

I have a feeling that I am doing this incorrectly - please let me know if there is some mechanism or common practice for integrating external code.

Thanks,
Paul

I wonder why no reply to an interesting point, is there any way, i am also interested…

+1

It would be great to have the stdout directly from the om-shell outlet.

A work around would be to write the stdout in a text file and the open it in OM, then you can process the text as you want.
Attached image with simple example retrieving ip information (OM 6.12 Ubuntu).

Screenshot_2017-08-06_01-24-09.png

Hi there. OM doesn’t propose any specific tool for that, but Common Lisp has a whole set of tools that allow Lisp programs to interact with standard input/output streams, that can (as usual) be used and included in your own tools :

http://www.lispworks.com/documentation/lw60/CLHS/Body/c_stream.htm
http://www.lispworks.com/documentation/lw60/CLHS/Body/v_debug_.htm

Jean

  • The underlying Lispworks functions that OM uses to execute external commands (or in om-shell) are run-shell-command and call-system/call-system-showing-output.

http://www.lispworks.com/documentation/lw70/LW/html/lw-1325.htm
http://www.lispworks.com/documentation/lw70/LW/html/lw-1233.htm

Both also allow to play with output streams, so it might be possible to read from these streams in order to set return values of a function.

Hi Jean,

I would like to run a python script with OM-shell.

I have read this page:
http://support.ircam.fr/docs/om/om6-manual/co/LowLevel.html
and tried something like “python3 --version” or “python3 filename.py”. But I didn’t succeed. The result was “python3: command not found”.

Could you give me simple examples for running

  • a python code,
  • even a simple code like (+ 1 2) ?

Dear Tsubasa,

In order to call python within OM, you can use either om-shell or om-terminal. The last one can even take multiple command lines.

Here is an example:

A) Calling just a python instruction such as 1+3
you should issue this command line:

python3 -c “print(3+1)”

B) Calling a python script:

python3 ~/Work/OMnewtoots/ompython/hello.py

Of course you must adapt your path and environment.

Here are the example files:

ompython.zip (1.3 KB)

Hope this helps.

Best
Karim

1 Like

Thank you Karim! Now I understood.