Stdout and Stderr

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

Stdout and Stderr

keith1y
Hello,

just a quick question, are any of the VM's particularly the unixish
ones, wired to produce output on stdout or stderr. Are there primitives
for doing so without any plugins?

thanks in advance

Keith

               
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com

Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

Giovanni Corriga
Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha scritto:
> Hello,
>
> just a quick question, are any of the VM's particularly the unixish
> ones, wired to produce output on stdout or stderr. Are there primitives
> for doing so without any plugins?

If you need output only, you can try opening /dev/stdout and /dev/stderr
as simple files.

This should work on Linux; not sure if it'll work on other Unix systems.

        Giovanni



Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

keith1y
Giovanni Corriga wrote:

> Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha scritto:
>  
>> Hello,
>>
>> just a quick question, are any of the VM's particularly the unixish
>> ones, wired to produce output on stdout or stderr. Are there primitives
>> for doing so without any plugins?
>>    
>
> If you need output only, you can try opening /dev/stdout and /dev/stderr
> as simple files.
>
> This should work on Linux; not sure if it'll work on other Unix systems.
>
> Giovanni
>  
Yes that worked!

stdout := FileDirectory new fileNamed: '/dev/stdout'
stdout nextPutAll: 'hello world'; cr.

:-)

Keith

               
___________________________________________________________
Copy addresses and emails from any email account to Yahoo! Mail - quick, easy and free. http://uk.docs.yahoo.com/trueswitch2.html

Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

Giovanni Corriga
Il giorno gio, 18/01/2007 alle 00.27 +0000, Keith Hodges ha scritto:

> Giovanni Corriga wrote:
> > Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha scritto:
> >  
> >> Hello,
> >>
> >> just a quick question, are any of the VM's particularly the unixish
> >> ones, wired to produce output on stdout or stderr. Are there primitives
> >> for doing so without any plugins?
> >>    
> >
> > If you need output only, you can try opening /dev/stdout and /dev/stderr
> > as simple files.
> >
> > This should work on Linux; not sure if it'll work on other Unix systems.
> >
> > Giovanni
> >  
> Yes that worked!

Just for the record, this works for reading from  stdin too, but
unfortunately it's a synchronous (blocking) read.

        Giovanni


Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

Bert Freudenberg

Am Jan 18, 2007 um 20:01  schrieb Giovanni Corriga:

> Il giorno gio, 18/01/2007 alle 00.27 +0000, Keith Hodges ha scritto:
>> Giovanni Corriga wrote:
>>> Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha scritto:
>>>
>>>> Hello,
>>>>
>>>> just a quick question, are any of the VM's particularly the unixish
>>>> ones, wired to produce output on stdout or stderr. Are there  
>>>> primitives
>>>> for doing so without any plugins?
>>>>
>>>
>>> If you need output only, you can try opening /dev/stdout and /dev/
>>> stderr
>>> as simple files.
>>>
>>> This should work on Linux; not sure if it'll work on other Unix  
>>> systems.
>>>
>>> Giovanni
>>>
>> Yes that worked!
>
> Just for the record, this works for reading from  stdin too, but
> unfortunately it's a synchronous (blocking) read.

Actually, when you use AsyncFile for reading, this works fine :)

In the OLPC image I use this to read commands from a pipe issued by  
an external process.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

David T. Lewis
On Thu, Jan 18, 2007 at 08:46:54PM +0100, Bert Freudenberg wrote:

>
> Am Jan 18, 2007 um 20:01  schrieb Giovanni Corriga:
>
> >Il giorno gio, 18/01/2007 alle 00.27 +0000, Keith Hodges ha scritto:
> >>Giovanni Corriga wrote:
> >>>Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha scritto:
> >>>
> >>>>Hello,
> >>>>
> >>>>just a quick question, are any of the VM's particularly the unixish
> >>>>ones, wired to produce output on stdout or stderr. Are there  
> >>>>primitives
> >>>>for doing so without any plugins?
> >>>>
> >>>
> >>>If you need output only, you can try opening /dev/stdout and /dev/
> >>>stderr
> >>>as simple files.
> >>>
> >>>This should work on Linux; not sure if it'll work on other Unix  
> >>>systems.
> >>>
> >>> Giovanni
> >>>
> >>Yes that worked!
> >
> >Just for the record, this works for reading from  stdin too, but
> >unfortunately it's a synchronous (blocking) read.
>
> Actually, when you use AsyncFile for reading, this works fine :)
>
> In the OLPC image I use this to read commands from a pipe issued by  
> an external process.

Yup, and you can also directly set a file stream for nonblocking
reads with #primitiveSQFileSetNonBlocking (OSPP comes with the
unix VM).  This permits direct reads from standard input as in
OSProcess class>>readFromStdIn.

Either way you can safely read from stdin without hanging the image.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

Bert Freudenberg
Am Jan 19, 2007 um 2:37  schrieb David T. Lewis:

> On Thu, Jan 18, 2007 at 08:46:54PM +0100, Bert Freudenberg wrote:
>>
>> Am Jan 18, 2007 um 20:01  schrieb Giovanni Corriga:
>>
>>> Il giorno gio, 18/01/2007 alle 00.27 +0000, Keith Hodges ha scritto:
>>>> Giovanni Corriga wrote:
>>>>> Il giorno mer, 17/01/2007 alle 22.41 +0000, Keith Hodges ha  
>>>>> scritto:
>>>>>
>>>>>> Hello,
>>>>>>
>>>>>> just a quick question, are any of the VM's particularly the  
>>>>>> unixish
>>>>>> ones, wired to produce output on stdout or stderr. Are there
>>>>>> primitives
>>>>>> for doing so without any plugins?
>>>>>>
>>>>>
>>>>> If you need output only, you can try opening /dev/stdout and /dev/
>>>>> stderr
>>>>> as simple files.
>>>>>
>>>>> This should work on Linux; not sure if it'll work on other Unix
>>>>> systems.
>>>>>
>>>>> Giovanni
>>>>>
>>>> Yes that worked!
>>>
>>> Just for the record, this works for reading from  stdin too, but
>>> unfortunately it's a synchronous (blocking) read.
>>
>> Actually, when you use AsyncFile for reading, this works fine :)
>>
>> In the OLPC image I use this to read commands from a pipe issued by
>> an external process.
>
> Yup, and you can also directly set a file stream for nonblocking
> reads with #primitiveSQFileSetNonBlocking (OSPP comes with the
> unix VM).  This permits direct reads from standard input as in
> OSProcess class>>readFromStdIn.
>
> Either way you can safely read from stdin without hanging the image.

Nice. I wonder ... IMHO we should make this available in the general  
VM IMHO. As well as primitives to open stdin/stdout/stderr.

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: Stdout and Stderr

David T. Lewis
On Fri, Jan 19, 2007 at 11:16:28AM +0100, Bert Freudenberg wrote:

> Am Jan 19, 2007 um 2:37  schrieb David T. Lewis:
>
> >On Thu, Jan 18, 2007 at 08:46:54PM +0100, Bert Freudenberg wrote:
> >>
> >>Am Jan 18, 2007 um 20:01  schrieb Giovanni Corriga:
> >>>
> >>>Just for the record, this works for reading from  stdin too, but
> >>>unfortunately it's a synchronous (blocking) read.
> >>
> >>Actually, when you use AsyncFile for reading, this works fine :)
> >>
> >>In the OLPC image I use this to read commands from a pipe issued by
> >>an external process.
> >
> >Yup, and you can also directly set a file stream for nonblocking
> >reads with #primitiveSQFileSetNonBlocking (OSPP comes with the
> >unix VM).  This permits direct reads from standard input as in
> >OSProcess class>>readFromStdIn.
> >
> >Either way you can safely read from stdin without hanging the image.
>
> Nice. I wonder ... IMHO we should make this available in the general  
> VM IMHO. As well as primitives to open stdin/stdout/stderr.

Unfortunately, this is hard to do in a platform-independent manner.
For example, Windows requires a separate thread to handle non-blocking
input, which seems like a lot of complexity for a primitive. And on
Windows, the stdin/stdout/stderr streams are not really very useful.
I don't know the situation for RiscOS and other platforms.

My impression (but I could be wrong) is that most people who care
about using stdin/stdout/stderr are using a unix-based platform
(including OS X), and the access to stdout/stderr and nonblocking
stdin is already available on those platforms. Of course, not too
many people *know* that it's available because it's partly hidden
away in an external package on SqueakMap, but that would be a poor
argument for adding more features to the base Squeak ;-)

Dave

p.s. The primitives for opening stdin/stdout/stderr are already
in OSPP for Windows, but I never did get nonblocking input to
work reliably.  I should go back and give it another try one of
these days.