[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

how to run a ruby program from another one

Navya Amerineni

2/28/2006 7:19:00 AM

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


---------------------------------
Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.
2 Answers

Bill Kelly

2/28/2006 7:35:00 AM

0

From: "Navya Amerineni" <navyaamerineni@yahoo.com>
>
> 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




Robert Klemme

2/28/2006 8:52:00 AM

0

Navya Amerineni 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