Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

does %x[] catch all output?

Tags:

ruby

If I run this code:

svn_output = %x[svn update /Users/radek/Sites/db2.rft -r 11105 --force ]
puts
puts " output is  =#{svn_output}="

I get this result

svn: Working copy '/Users/radek/Sites/db2.rft' locked
svn: run 'svn cleanup' to remove locks (type 'svn help cleanup' for details)

 output is  ==

but I want the error message from svn inside the variable svn_output. Is that possible?

like image 247
Radek Avatar asked Mar 24 '11 04:03

Radek


1 Answers

You want to redirect stderr to stdout:

svn_output = %x[svn update /Users/radek/Sites/db2.rft -r 11105 --force 2>&1]
puts
puts " output is  =#{svn_output}="
like image 108
yan Avatar answered Sep 21 '22 00:09

yan