From: Avdi Grimm Date: 2011-02-17T11:09:56+09:00 Subject: Re: capturing stderr for a file On Wed, Feb 16, 2011 at 7:04 PM, Ted Flethuseo 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