On Wed, Feb 16, 2011 at 7:04 PM, Ted Flethuseo <flethuseo / gmail.com> wrote:
> I am trying to run a script from ruby, but it produces some output to
> STDERR. It isn't capturing that output. How do I capture it?

Two options:

1. Redirect STDOUT to STDERR in the command:

output = `./script.sh #{e} 2>&1`

2. Use Open3 to capture the error stream:

require 'open3'
Open3.popen3("./script.sh #{e} 2>&1") do |i, o, e|
  puts "STDOUT: #{o.read}"
  puts "STDERR: #{e.read}"
end