System() help

system() does not do anyting with stdout or stdin, and it returns true
or false depending on the command exit code. If you want to collect the
program's stdin, the easiest way would be to use backquotes:

@myresult = `ls`

If you want to collect stderr as well, depending on you system shell you
can do something like:

@myresult = `command_writing_to_stderr 2>&1`

Or you can deal with forking and exec-ing a command explicitelly, using
pipe() and redirecting stdout/stderr anyway you like (you may also want
to take a look at popen()).

Gennady.

ยทยทยท

-----Original Message-----
From: list-bounce@example.com
[mailto:list-bounce@example.com] On Behalf Of zac elston
Sent: Tuesday, February 21, 2006 12:27
To: ruby-talk ML
Subject: system() help

are there any docs describing how to get stderr vs stdout
from a system()?

@myresult = system(mycmd)
works only if I have stdout returned but not stderr.

thanks

--
Posted via http://www.ruby-forum.com/\.