How do I call shell commands from inside of a Ruby program? How do I then get output from these commands back into Ruby?
Some things to think about when choosing between these mechanisms are:
You may need anything from simple backticks (``), system()
, and IO.popen
to full-blown Kernel.fork
/Kernel.exec
with IO.pipe
and IO.select
.
You may also want to throw timeouts into the mix if a sub-process takes too long to execute.
Unfortunately, it very much depends.