[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Execute one Ruby script from inside another...

sketchitup@gmail.com

7/27/2007 7:39:00 PM

Is it possible to execute one Ruby script from inside another Ruby
script? What is the syntax for this? Can arguments be passed to the
second script from inside the first?

What about other external programs? Can Ruby execute those?

Thanks for the help.

The SketchUp Artist

2 Answers

sketchitup@gmail.com

7/27/2007 7:43:00 PM

0

On Jul 27, 12:38 pm, "sketchi...@gmail.com" <sketchi...@gmail.com>
wrote:
> Is it possible to execute one Ruby script from inside another Ruby
> script? What is the syntax for this? Can arguments be passed to the
> second script from inside the first?
>
> What about other external programs? Can Ruby execute those?
>
> Thanks for the help.
>
> The SketchUp Artist

I apologize. I just found the answer to the first part of my question
in this article:

http://ruby.about.com/od/learnruby/ss/require_...

I'd still like to know if Ruby can execute external programs.

Thanks,

The SketchUp Article

Sebastian Hungerecker

7/27/2007 7:58:00 PM

0

sketchitup@gmail.com wrote:
> I'd still like to know if Ruby can execute external programs.

It sure can:

system("app")
will execute app with the parameters arg1 and arg2. It will return true if the
programm exited successfully, false otherwise. app's output will go to stdout
(unless you redirect it).

`app` or %x{app}
will execute app and return its output as a string.

IO::popen("app",mode)
will execute app and immediately return an IO object (i.e. unlike the previous
options it won't wait for app to finish). You will be able to interact with
app using said IO object.

Open3::popen3("app")
works the same way as popen, except it gives you *three* IO objects. One to
write to app's input stream, one to read from its output stream and one to
read from its error stream.

That's it.

HTH,
Sebastian
--
NP: Anathema - Are you there?
Ist so, weil ist so
Bleibt so, weil war so