reading stdin (was: how to write to stdOut and stdErr under Cog)

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

reading stdin (was: how to write to stdOut and stdErr under Cog)

Chris Muller-4
Hi, I did some more work with this tonight; integrating it into a nice
command-line facade.  It works pretty well.  One question I have
pertains to reading the stdin stream.

I can read stdin when I have redirected input to the squeak
executable.  It works great and even allows tick marks to be passed
in.

However, there is not a safe way to know if any input _was_
redirected.  #atEnd answers false even when no input was redirected,
so programs are inclined to read the stream..  Unfortunately, any
access to the stdin stream (via #next, #next:, #upToAll, etc.) when no
input was redirected seems to lock up the image instantly; can only
kill -9..  :(  Is there another way to do this?

 - Chris


On Sun, Sep 26, 2010 at 7:09 PM, Eliot Miranda <[hidden email]> wrote:

> Hi Chris,
>     I have code for this, but right now I need to crack some crabs, so I
> don't have time to verify this code in 4.1 :)  Use at your own risk ;)  The
> most important thing is the StandardFileStream>>stdioHandles primitive for
> accessing the streams.  N.B. some work needs to be done on the win32
> FilePlugin support code before this will work on Windows.
>
>
> On Sun, Sep 26, 2010 at 2:46 PM, Chris Muller <[hidden email]> wrote:
>>
>> I am developing a simple "CommandLineProcessor" facade for easily
>> transferring command-line arguments simply as block-arguments, so you
>> can write smalltalk scripts in vi:
>>
>>  CommandLineProcessor do: [ : arg1 : arg2 : arg3 | "args come in as
>> Strings" ... ]
>>
>> and also for directing Notifications and Warnings messages to stdOut,
>> and Errors to stdErr.  It relies on OSProcess to write to stdOut and
>> stdErr for this.  However, ever since switching to Cog, writing to
>> these streams does not seem to redirect out to Linux..
>>
>> I don't know whether writing to these streams makes me
>> Linux-dependent, but it really is nice to be able to write Linux
>> scripts that employ Squeak in the back-end, but operate normally like
>> other shell programs in the terminal window and with redirecting
>> output, etc.
>>
>>  - Chris
>>
>
>