Monday, 15 June 2015

How to redirect STDOUT and STDERR in Ruby and make them equal? -



How to redirect STDOUT and STDERR in Ruby and make them equal? -

when phone call command in ruby %x{command}, standard output captured, , standard error shows on screen. both captured , want watch both on screen too. how can accomplish this?

%x{command 2>&1 1>&2}

construction seems not working.

2.1.3 :005 > %x{(ls -d /boot 2>&1) | tee /dev/stderr} /boot => "/boot\n" 2.1.3 :006 > %x{(ls /no_such_file 2>&1) | tee /dev/stderr} ls: cannot access /no_such_file: no such file or directory => "ls: cannot access /no_such_file: no such file or directory\n"

ruby redirect stdout stderr

No comments:

Post a Comment