Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 22 hours, 46 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

Calling External Scripts

Author 4 Subscribed Users |
Profile photo of pbrook
pbrook

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

April 3, 2016 at 08:12 #17611
Profile photo of ratox
ratox

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

August 5, 2017 at 14:24 #23370
Profile photo of rc
rc

+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).

Attachments:
  1. Screenshot_2017-08-06_01-24-09

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

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

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

August 6, 2017 at 01:01 #23371
Profile photo of Jean
Jean

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

August 8, 2017 at 08:29 #23375
Profile photo of Jean
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.

August 8, 2017 at 08:38 #23376

You must be logged in to reply to this topic.

Log in now