Forum: Ruby how to run a ruby program from another one

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
4e232c97651b0f51d8799c0f46a2011d?d=identicon&s=25 Navya Amerineni (Guest)
on 2006-02-28 08:21
(Received via mailing list)
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
4feed660d3728526797edeb4f0467384?d=identicon&s=25 Bill Kelly (Guest)
on 2006-02-28 08:37
(Received via mailing list)
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
5befe95e6648daec3dd5728cd36602d0?d=identicon&s=25 Robert Klemme (Guest)
on 2006-02-28 09:56
(Received via mailing list)
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
This topic is locked and can not be replied to.