My simple test program:
pid = Process.spawn("sleep 10;date")
How can I place the output (eg stdout) of the "date" command in a variable when it is available? I don't want to use a file for the data exchange.
My simple test program:
pid = Process.spawn("sleep 10;date")
How can I place the output (eg stdout) of the "date" command in a variable when it is available? I don't want to use a file for the data exchange.
There are a whole bunch of ways to run commands from Ruby. The simplest for your case is to use backticks, which capture output:
If you want something more similar to
Process.spawn
, use the open3 stdlib: