Forum: Ruby system() help

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Zac E. (Guest)
on 2006-02-21 22:26
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
Eero S. (Guest)
on 2006-02-21 22:31
zac elston wrote:
> 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.

You might want to look at IO.popen or Open3 from the
stdlib (Open3.popen) if you need anything more than
your platform's C system() call.

> thanks


E
(Guest)
on 2006-02-21 22:40
(Received via mailing list)
Look up 'open3' in the standard library:
http://ruby-doc.org/stdlib/libdoc/open3/rdoc/index.html

require "open3"
stdin, stdout, stderr = Open3.popen3('man ruby')

(You don't have to use stdin if you don't want to)
This topic is locked and can not be replied to.