Hello,
Is there a way to execute an external process from squeak and get its input, output and error streams? (something like popen() )
Yoel
Yoel Jacobsen wrote:
Hello,
Is there a way to execute an external process from squeak and get its input, output and error streams? (something like popen() )
Take a look at OSProcess:
http://minnow.cc.gatech.edu/squeak/708
Michael
On Sun, Jul 28, 2002 at 08:54:23AM +0200, Yoel Jacobsen wrote:
Is there a way to execute an external process from squeak and get
its input, output and error streams? (something like popen() )
Assuming that you are using a Unix or Linux system, load the OSProcess (http://minnow.cc.gatech.edu/squeak/708) and CommandShell (http://minnow.cc.gatech.edu/squeak/1914) change sets.
To run an external process with access to input/output/error streams: | p | p _ PipeableOSProcess command: 'ls -l * NONESUCH'. p output inspect. p errorUpToEnd inspect.
or: | p | p _ PipeableOSProcess command: 'cat'. p nextPutAll: 'hello world!'. p close. p output inspect.
Note: PipeableOSProcess>>output will block on the pipe read, so be sure to do the #close. See PipeableOSProcess>>upToEnd for a nonblocking read.
If you have recently downloaded Ian's Unix VM, the required plugin (UnixOSProcessPlugin.so) is already included, so just load the change sets and all should be well. Otherwise, source code for the plugin is included in the OSProcess change set.
Dave
Has anyone tried this on OS X? I'll try it in a bit, but thought I'd ask first. (1 week away from email leads to hours digging out from under...)
Mark
On Sunday, July 28, 2002, at 07:49 AM, David T. Lewis wrote:
On Sun, Jul 28, 2002 at 08:54:23AM +0200, Yoel Jacobsen wrote:
Is there a way to execute an external process from squeak and get
its input, output and error streams? (something like popen() )
Assuming that you are using a Unix or Linux system, load the OSProcess (http://minnow.cc.gatech.edu/squeak/708) and CommandShell (http://minnow.cc.gatech.edu/squeak/1914) change sets.
To run an external process with access to input/output/error streams: | p | p _ PipeableOSProcess command: 'ls -l * NONESUCH'. p output inspect. p errorUpToEnd inspect.
or: | p | p _ PipeableOSProcess command: 'cat'. p nextPutAll: 'hello world!'. p close. p output inspect.
Note: PipeableOSProcess>>output will block on the pipe read, so be sure to do the #close. See PipeableOSProcess>>upToEnd for a nonblocking read.
If you have recently downloaded Ian's Unix VM, the required plugin (UnixOSProcessPlugin.so) is already included, so just load the change sets and all should be well. Otherwise, source code for the plugin is included in the OSProcess change set.
Dave
On Tue, Jul 30, 2002 at 03:34:41PM -0400, Mark Guzdial wrote:
Has anyone tried this on OS X? I'll try it in a bit, but thought I'd ask first. (1 week away from email leads to hours digging out from under...)
Mark
Mark, OSProcess is not yet working on OS-X but hopefully will be soon.
Dave
squeak-dev@lists.squeakfoundation.org