Hi everyone,
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?
file = File.open(“my.txt”, “w”)
arr.each do |e|
file.puts ./script.sh #{e}
end
Ted.
Hi everyone,
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?
file = File.open(“my.txt”, “w”)
arr.each do |e|
file.puts ./script.sh #{e}
end
Ted.
On Wed, Feb 16, 2011 at 7:04 PM, Ted F. [email protected]
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:
output = ./script.sh #{e} 2>&1
require ‘open3’
Open3.popen3(“./script.sh #{e} 2>&1”) do |i, o, e|
puts “STDOUT: #{o.read}”
puts “STDERR: #{e.read}”
end
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs