Getting the output of a system command

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

Getting the output of a system command

ZuLuuuuuu
Hello,

My intention is to write the output of a command I execute inside my application, into a graphical widget. But first I have to get the output from execution. When I execute a command like this:

Smalltalk system: 'bla bla bla'

it returns the exit code. When I execute a command via opening a pipe:

pipe := FileStream popen: 'bla bla bla' dir: FileStream read.

I can get the "normal" output by #nextLine etc. But if it exits with an exit code different then 0, I cannot read any output, for example, #nextLine returns nil. How can I get the error message as well?


Canol

Sorry if this has been a double post.
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: Getting the output of a system command

Stefan Schmiedl
On Fri, 10 Dec 2010 03:50:16 -0800 (PST)
ZuLuuuuuu <[hidden email]> wrote:

> pipe := FileStream popen: 'bla bla bla' dir: FileStream read.
>
> I can get the "normal" output by #nextLine etc. But if it exits with an exit
> code different then 0, I cannot read any output, for example, #nextLine
> returns nil. How can I get the error message as well?

Getting the "normal" output probably means that you are capturing the
called program's stdout.

Does the program write to stdout at all in case of the faulty exit?

Run the aborting with output redirection

        bla bla bla 1>stdout.log 2>stderr.log

and make sure that stdout.log is not empty.

s.

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk