# Re: system() help

**URL:** <https://www.ruby-forum.com/t/re-system-help/71577>\
**Category:** Ruby\
**Created:** [February 21, 2006, 9:46pm UTC](https://www.ruby-forum.com/t/re-system-help/71577 "2006-02-21T21:46:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gennady\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c57346/32.png) [@Gennady\_B](https://www.ruby-forum.com/u/Gennady_B)\
**Post date:** [February 21, 2006, 9:46pm UTC](https://www.ruby-forum.com/t/re-system-help/71577/1 "2006-02-21T21:46:50Z")

</div>

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.
