G
Garance A Drosihn
Sometimes I write ruby scripts to filter the output of some
other command. So I write something like:
cmdout = IO.popen(somecmd, "r")
cmdout.each_line {|aline|
# Do Stuff...
}
cmdout.close
Is there any way to find out what the exit status was from
the command given to popen? It would be nice to have some
method that I could use like:
if cmdout.popen_exit_status != 0
# Do Error-processing stuff
end
which could be done after reading all the lines, but before
the call to 'close'.
Or do I need to do something more complicated than 'popen'
if I need to know the exit code from that command?
other command. So I write something like:
cmdout = IO.popen(somecmd, "r")
cmdout.each_line {|aline|
# Do Stuff...
}
cmdout.close
Is there any way to find out what the exit status was from
the command given to popen? It would be nice to have some
method that I could use like:
if cmdout.popen_exit_status != 0
# Do Error-processing stuff
end
which could be done after reading all the lines, but before
the call to 'close'.
Or do I need to do something more complicated than 'popen'
if I need to know the exit code from that command?