# How to run a ruby program from another one

**URL:** <https://www.ruby-forum.com/t/how-to-run-a-ruby-program-from-another-one/74585>\
**Category:** Ruby\
**Created:** [February 28, 2006, 8:21am UTC](https://www.ruby-forum.com/t/how-to-run-a-ruby-program-from-another-one/74585 "2006-02-28T08:21:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Navya\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8baadc/32.png) [@Navya\_A](https://www.ruby-forum.com/u/Navya_A)\
**Post date:** [February 28, 2006, 8:21am UTC](https://www.ruby-forum.com/t/how-to-run-a-ruby-program-from-another-one/74585/1 "2006-02-28T08:21:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Navya\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8baadc/32.png) [@Navya\_A](https://www.ruby-forum.com/u/Navya_A)\
**Post date:** [February 28, 2006, 8:37am UTC](https://www.ruby-forum.com/t/how-to-run-a-ruby-program-from-another-one/74585/2 "2006-02-28T08:37:25Z")

</div>

From: “Navya A.” [removed\_email\_address@domain.invalid](mailto: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

---

<div class="post-metadata">

**Author:** ![Navya\_A](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/8baadc/32.png) [@Navya\_A](https://www.ruby-forum.com/u/Navya_A)\
**Post date:** [February 28, 2006, 9:56am UTC](https://www.ruby-forum.com/t/how-to-run-a-ruby-program-from-another-one/74585/3 "2006-02-28T09:56:43Z")

</div>

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
```
