[squeak-dev] [OSProcess] How to read the stdout of a process running an infinite loop?

David T. Lewis lewis at mail.msen.com
Wed May 21 02:48:21 UTC 2008


On Tue, May 20, 2008 at 05:10:45PM +0200, Noury Bouraqadi wrote:
> Hi,
> 
> Gautier and I have a software written in C that loops infinitly doing  
> some computations. At every iteration it displays something on the  
> shell. We want to read the output into squeak. We can not wait for the  
> end of the computations, since it's an infinite loop :-)
> 
> Any hints?

Try the attached change set for an example. I made a shell script that
generates output, named it "test.sh", and ran it from Squeak as follows.

	| proxyWatcher |
	proxyWatcher := ReadFromExternalProgram programName: 'test.sh'.
	proxyWatcher start.
	(Delay forSeconds: 10) wait.
	proxyWatcher stop.

The proxyWatcher runs the external program for 10 seconds, copying its
output to the Transcript as new data becomes available.

Hope this helps,
Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ReadFromExternalProgram-dtl.2.cs.gz
Type: application/octet-stream
Size: 999 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20080520/1dfa1874/ReadFromExternalProgram-dtl.2.cs.obj


More information about the Squeak-dev mailing list