Hi!
I would like to run a program from ruby and be able to give it its input and
receive the output. This program usually uses stdin and stdout. How may I
achieve this?
Thanks!
Hi,
At Sun, 29 May 2005 06:14:04 +0900,
Danny Beaudoin wrote in [ruby-talk:143900]:
I would like to run a program from ruby and be able to give it its input and
receive the output. This program usually uses stdin and stdout. How may I
achieve this?
cmd = IO.popen("program arg1 arg2", "r+")
cmd.puts(data)
cmd.close_write
result = cmd.read
close_write might be unnecessary depending on the program, if it
doesn't wait EOF of stdin.
ยทยทยท
--
Nobu Nakada