Run a command line with custom environment
Open.popen3
optionally accepts a hash as the first argument (in which case your command would be the second argument:
cmd = 'a_prog --arg ... --arg2 ...'Open3.popen3({"MYVAR" => "a_value"}, "#{cmd}") { |i,o,e| output = o.read() error = e.read() # FIXME: don't want to *separate out* stderr like this repr = "$ #{cmd}\n#{output}"}
Open
uses Process.spawn
to start the command, so you can look at the documentation for Process.spawn to see all of it's options.