How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
One more option:
When you:
You can use shell redirection:
puts %x[cat bogus.txt].inspect
=> ""
puts %x[cat bogus.txt 2>&1].inspect
=> "cat: bogus.txt: No such file or directory\n"
The 2>&1
syntax works across Linux, Mac and Windows since the early days of MS-DOS.