I suspect that this is an extremely simple question to answer.
How do you capture the output of a system call?
For example, if I do this:
x = system("date")
Thu Jun 18 13:00:00 CDT 2009
=> true
x
=> true
I would like to capture the output of the date command. How do I do it?
Thanks,
Wes
···
--
Posted via http://www.ruby-forum.com/.
x = `date`
if you need to capture more than just stdout, i recommend the systemu gem.
best,
michael guterl
···
On Thu, Jun 18, 2009 at 2:01 PM, Wes Gamble<weyus@att.net> wrote:
I suspect that this is an extremely simple question to answer.
How do you capture the output of a system call?
For example, if I do this:
x = system("date")
Thu Jun 18 13:00:00 CDT 2009
=> true
x
=> true
I would like to capture the output of the date command. How do I do it?
There's also IO.popen and Open3.popen which are part of the standard
library IIRC.
Kind regards
robert
···
2009/6/18 Michael Guterl <mguterl@gmail.com>:
On Thu, Jun 18, 2009 at 2:01 PM, Wes Gamble<weyus@att.net> wrote:
I suspect that this is an extremely simple question to answer.
How do you capture the output of a system call?
For example, if I do this:
x = system("date")
Thu Jun 18 13:00:00 CDT 2009
=> true
x
=> true
I would like to capture the output of the date command. How do I do it?
x = `date`
if you need to capture more than just stdout, i recommend the systemu gem.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/