Newbie question: Calling a shell script from ruby

Hi

Apologies if this question is already answered in the doc. How do I call a
shell script from within ruby code? I have a lot of existing scripts that
are written in perl and I’d like to call them from a ruby framework. I
haven’t found anything in the doc about this, maybe I missed something?

Regards

Zubin

shell script

Just like in a shell script. There’s more information in the Pickaxe.

Gavin

···

----- Original Message -----
From: “Sethna, Zubin” ZSethna@rsasecurity.com.au
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Wednesday, September 25, 2002 9:50 AM
Subject: Newbie question: Calling a shell script from ruby

Hi

Apologies if this question is already answered in the doc. How do I call a
shell script from within ruby code? I have a lot of existing scripts that
are written in perl and I’d like to call them from a ruby framework. I
haven’t found anything in the doc about this, maybe I missed something?

Regards

Zubin

A simple way is

system(“/some/where/foo.sh”)

See also:

http://www.rubycentral.com/book/ref_m_kernel.html#Kernel.system
http://www.ruby-lang.org/en/man-1.4/syntax.html#command
http://www.rubycentral.com/book/ref_m_kernel.html#Kernel.fork
http://www.rubycentral.com/book/ref_m_kernel.html#Kernel.exec
http://www.rubycentral.com/book/ref_c_io.html#IO.popen
http://www.ruby-lang.org/~knu/cgi-bin/cvsweb.cgi/ruby/lib/open3.rb?rev=1.6.2.4&content-type=text/x-cvsweb-markup

– Gotoken

···

At Wed, 25 Sep 2002 08:50:01 +0900, Sethna, Zubin ZSethna@rsasecurity.com.au wrote:

Apologies if this question is already answered in the doc. How do I call a
shell script from within ruby code? I have a lot of existing scripts that
are written in perl and I’d like to call them from a ruby framework. I
haven’t found anything in the doc about this, maybe I missed something?