help-smalltalk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-smalltalk] piped shell stopping second piped shell


From: Stephen
Subject: [Help-smalltalk] piped shell stopping second piped shell
Date: Mon, 16 Jun 2008 08:50:15 +1200
User-agent: Thunderbird 2.0.0.14 (Macintosh/20080421)

Hi everyone,

I've got a scenario where I'm using gst to run a shell command, and then using the output to run an iteration within which is another shell command.

It looks like there could be a gst bug stopping this from working.

Here is a trivial sample (it isn't meaningful, but shows the problem):

shellCmd := 'ls -l /etc'.
filelistPipe := FileStream popen: shellCmd dir: FileStream read.
filelist := filelistPipe contents.
filelist linesDo: [ :shortname |
   shellCmd2 := 'ls /etc/skel'.
   pipe2 := FileStream popen: shellCmd2 dir: FileStream read.
   Transcript showCr: pipe2 contents.
   Transcript showCr: ' --------------------------- '.
].

The problem is that the "filelist linesDo" block doesn't loop. There is no output from the loop.



In contrast, this code works as expected where have only changed the loop condition: (result is 3 iterations) ...

shellCmd := 'ls -l /etc'.
filelistPipe := FileStream popen: shellCmd dir: FileStream read.
filelist := filelistPipe contents.
1 to: 3 do: [ :counter |
   shellCmd2 := 'ls /etc/skel'.
   pipe2 := FileStream popen: shellCmd2 dir: FileStream read.
   Transcript showCr: pipe2 contents.
   Transcript showCr: ' --------------------------- '.
].


And the code below works as expected where have omitted the second shell call: ( result is as many iterations as there are lines in the "ls -l /etc" listing) ...

shellCmd := 'ls -l /etc'.
filelistPipe := FileStream popen: shellCmd dir: FileStream read.
filelist := filelistPipe contents.
filelist linesDo: [ :shortname |
   Transcript showCr: ' --------------------------- '.
].


Am seeing this behaviour in both gst 3.0b on Mac OS X, and also in gst 3.0 (an early release) on Linux.


Thank you
Stephen




reply via email to

[Prev in Thread] Current Thread [Next in Thread]