CommandShell and stream protocol

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

CommandShell and stream protocol

frits.swinkels
I installed CommandShell in a small 3.7 image.

On evaluating the following line in a bash shell I get a 4 lines
response of file paths
find /home/frits/DB -exec grep -q "France" ''{}'' \; -print

When I evaluate
command := PipeableOSProcess command: ' find /home/frits/DB -exec grep
-q "France" ''{}'' \; -print' . in a workspace I get a string with the
correct 4 file names separated by ASCII 10.

The documentation (almost unique in the Squeak world, thanks;) states
that there are three streams: input output and error. Thus I expected to
use a stream protocol like:

command := PipeableOSProcess etc
output := command output.
[output atEnd] whileFalse: [ output next......]
and get myself a list (and not a string) of file names.

I must misunderstand something. Any way of achieving such an result:
e.g. a pipe which blocks till items are removed?

(I googled and searched the archives, no luck although I believe this
must have come up before.)



Reply | Threaded
Open this post in threaded view
|

Re: CommandShell and stream protocol

David T. Lewis
Hi Frits,

I am away from my computers for the holiday (USA Thanksgiving) so I
can't give you a good answer right now. But from memory, the method
PipeableOSProcess class>>command is just a convenience method that
runs the command and gives you the contents of the output stream. The
actual instances of PipeableOSProcess have the streams that you are
looking for, so if you step through your example in a debugger you
will see them.

I should mention that I have done a rewrite of most of CommandShell
which I hope will do a better job of handling piping and other issues.
This is on SqueakSource, but I have not gotten around to releasing
it on SqueakMap or Universes (partly because I have not updated the
documentation). Nevertheless, if you are interested in experimenting
with pipes and OS process pipelines, you may want to try loading the
latest versions of OSProcess and CommandShell directly from SqueakSource.

Dave


On Wed, Nov 21, 2007 at 03:18:41PM -0800, frits.swinkels wrote:

> I installed CommandShell in a small 3.7 image.
>
> On evaluating the following line in a bash shell I get a 4 lines
> response of file paths
> find /home/frits/DB -exec grep -q "France" ''{}'' \; -print
>
> When I evaluate
> command := PipeableOSProcess command: ' find /home/frits/DB -exec grep
> -q "France" ''{}'' \; -print' . in a workspace I get a string with the
> correct 4 file names separated by ASCII 10.
>
> The documentation (almost unique in the Squeak world, thanks;) states
> that there are three streams: input output and error. Thus I expected to
> use a stream protocol like:
>
> command := PipeableOSProcess etc
> output := command output.
> [output atEnd] whileFalse: [ output next......]
> and get myself a list (and not a string) of file names.
>
> I must misunderstand something. Any way of achieving such an result:
> e.g. a pipe which blocks till items are removed?
>
> (I googled and searched the archives, no luck although I believe this
> must have come up before.)
>
>

Reply | Threaded
Open this post in threaded view
|

Re: CommandShell and stream protocol

frits.swinkels
Indeed I found the actual pipes in the instance of PipeableOSProcess.
Thanks for the fast reply and I will go hunt for the SqueakSource version.

David T. Lewis wrote:

> Hi Frits,
>
> I am away from my computers for the holiday (USA Thanksgiving) so I
> can't give you a good answer right now. But from memory, the method
> PipeableOSProcess class>>command is just a convenience method that
> runs the command and gives you the contents of the output stream. The
> actual instances of PipeableOSProcess have the streams that you are
> looking for, so if you step through your example in a debugger you
> will see them.
>
> I should mention that I have done a rewrite of most of CommandShell
> which I hope will do a better job of handling piping and other issues.
> This is on SqueakSource, but I have not gotten around to releasing
> it on SqueakMap or Universes (partly because I have not updated the
> documentation). Nevertheless, if you are interested in experimenting
> with pipes and OS process pipelines, you may want to try loading the
> latest versions of OSProcess and CommandShell directly from SqueakSource.
>
> Dave
>
>
> On Wed, Nov 21, 2007 at 03:18:41PM -0800, frits.swinkels wrote:
>  
>> I installed CommandShell in a small 3.7 image.
>>
>> On evaluating the following line in a bash shell I get a 4 lines
>> response of file paths
>> find /home/frits/DB -exec grep -q "France" ''{}'' \; -print
>>
>> When I evaluate
>> command := PipeableOSProcess command: ' find /home/frits/DB -exec grep
>> -q "France" ''{}'' \; -print' . in a workspace I get a string with the
>> correct 4 file names separated by ASCII 10.
>>
>> The documentation (almost unique in the Squeak world, thanks;) states
>> that there are three streams: input output and error. Thus I expected to
>> use a stream protocol like:
>>
>> command := PipeableOSProcess etc
>> output := command output.
>> [output atEnd] whileFalse: [ output next......]
>> and get myself a list (and not a string) of file names.
>>
>> I must misunderstand something. Any way of achieving such an result:
>> e.g. a pipe which blocks till items are removed?
>>
>> (I googled and searched the archives, no luck although I believe this
>> must have come up before.)
>>
>>
>>    
>
>