Forum: Ruby Re: Calling Shell Scripts from Ruby ?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Gennady B. (Guest)
on 2006-05-03 20:59
(Received via mailing list)
> 1)Is it possible to call "Shell Scripts" from ruby? Say if i
> have a shell sciprt named "", how can i call this from
> ruby? Also if i can call like that,is it possible to get the
> output of that script passed back to ruby?

Shell scripts fall into "any Unix command" category, so keep on reading.

> 2)How can i call any "Unix command" residing from a ruby program??

1. Backquotes

result = ``

2. exec(), fork/exec

exec ''
Process.wait fork {
  exec ''

3. popen(), popen3(), etc.

IO.popen('') { |_io|

4. Good old system()


Read about all those facilities in the documentation to get the most out
of it.

This topic is locked and can not be replied to.