How to redirect STDERR to STDOUT in the context of a Ruby program maintaning portability? -


i redirect stderr stdout in %x{} statement. used in past %x{program 2>&1} think won't work on windows or other systems. how in more rubysh way maintain compatibility , portability, want make work script on every possible system.

you can read both stderr , stdout, example.

require 'open3'  open3.popen3('ls error') |stdin, stdout, stderr, wt|   stdout.write(stdout.read)   stdout.write(stderr.read) end 

running it.

$ ruby example.rb 2>/dev/null ls: error: no such file or directory 

Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

clojure - 'get' replacement that throws exception on not found? -