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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -