When I use IO::popen with a non-existent command, I get an error message printed to the screen:
irb> IO.popen "fakefake"
#=> #<IO:0x187dec>
irb> (irb):1: command not found: fakefake
Is there any way I can capture this error, so I can examine from within my script?
Yes: Upgrade to ruby 1.9. If you run that in 1.9, an
Errno::ENOENTwill be raised instead, and you will be able torescueit.(Edit) Here is a hackish way of doing it in 1.8: