How to run a ruby program from another one


#1

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.

Please help.

Thanks,
Navya


#2

From: “Navya A.” removed_email_address@domain.invalid

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


#3

Navya A. wrote:

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