how to run a ruby program from another one

N

Navya Amerineni

--0-461448927-1141111104=:49361
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable

Hi,

How can we run a a ruby program from another ruby program. I am working o=
n one program where in i have to run another ruby program from it.
I am stuck here.

Please help.

Thanks,
Navya

=09
 
B

Bill Kelly

From: "Navya Amerineni said:
How can we run a a ruby program from another ruby program. I am
working on one program where in i have to run another ruby program
from it.

Hi,

Usually

result = `other_program`

or

system("other_program")

or

io = IO.popen("other_program", "r") # or "w" if you want to write to it
io.gets # ... read stdout from other_program
...


Regards,

Bill
 
R

Robert Klemme

Navya said:
Hi,

How can we run a a ruby program from another ruby program. I am
working on one program where in i have to run another ruby program
from it.
I am stuck here.

The easiest is to use fork with a block:

09:51:31 [~]: ruby -e 'fork { puts "#{$$}: child" }; puts "#{$$}: parent"'
1912: parent
2128: child

Kind regards

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top