System() help


#1

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


#2

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


#3

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)