Sulo Wijetunga Sulo Wijetunga - 4 months ago 48
Ruby Question

How to read sterr status from Ruby?

I have following ruby and not working properly

my_command = %x{java -version &>/dev/null}
if $? != 0

In this how do I see what the stderr/stdout status code?
I tried put below, nothing works..

puts "values ===> $? or or '$?' my_command or #{my_command} %x{echo $?}"


To get the status code :

stdout    = %x(ls -l)
exit_code = $?.exitstatus

and then

if exit_code == 0 then
  puts "Success"
  puts "Problem"