Whenever you want to execute something on the command line, you can use the following syntax:
%x(command to run)
However, I want to catch a
You need a mix of @Cam 's answer and @tonttu 's answer.
decent explanation of $? and others.
Edit: the domain http://blog.purifyapp.com is now in hands of a domain-squatter and scammer.
result = %x(command to run 2>&1)
unless $? == 0 #check if the child process exited cleanly.
puts "got error #{result}"
end