[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Starting a system command and letting it be?

darenbell@gmail.com

11/10/2006 2:33:00 PM

I'm writing a web service that accepts a call to initiate a few
self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
can't seem to find any documentation on how I could kick off the
scripts without having the parent script wait on them to complete.
Obviously, I don't need arguments our output back from the scripts, so
all I'm concerned with is that they start and the parent can end
without killing them.

What's the best way to do this?

8 Answers

Farrel Lifson

11/10/2006 2:42:00 PM

0

On 10/11/06, darenbell@gmail.com <darenbell@gmail.com> wrote:
> I'm writing a web service that accepts a call to initiate a few
> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> can't seem to find any documentation on how I could kick off the
> scripts without having the parent script wait on them to complete.
> Obviously, I don't need arguments our output back from the scripts, so
> all I'm concerned with is that they start and the parent can end
> without killing them.
>
> What's the best way to do this?
>
>
>

You could just use ruby threads?

Farrel

Ara.T.Howard

11/10/2006 2:43:00 PM

0

Nathan Witmer

11/10/2006 3:00:00 PM

0

> What's the best way to do this?

Have a look at BackgrounDRb, it's a rails plugin designed specifically
for this type of thing: kicking off long-running tasks without making
rails wait for it to finish. You'll still probably use system() for
running your script, but if you use one of the popens (2, 3, or 4) you
can get stdout and feed that back to the rails app incrementally.

Here's an introductory article: http://www.infoq.com/articles/Ba...
and the rubyforge page: http://rubyforge.org/projects/bac...

darenbell@gmail.com

11/10/2006 3:35:00 PM

0

OK, that was too obvious. :)

Works fine in a local script, but my web service client is just sitting
there waiting. Guess that's the problem.

On Nov 10, 8:43 am, ara.t.how...@noaa.gov wrote:
> On Fri, 10 Nov 2006, darenb...@gmail.com wrote:
> > I'm writing a web service that accepts a call to initiate a few
> > self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> > can't seem to find any documentation on how I could kick off the
> > scripts without having the parent script wait on them to complete.
> > Obviously, I don't need arguments our output back from the scripts, so
> > all I'm concerned with is that they start and the parent can end
> > without killing them.
>
> > What's the best way to do this?by far the simplest is
>
> system "in_the_background &"
>
> -a
> --
> my religion is very simple. my religion is kindness. -- the dalai lama

darenbell@gmail.com

11/10/2006 3:39:00 PM

0

OK, that was too obvious. :)

Works fine in a local script, but my web service client is just sitting
there waiting. Guess that's the problem.

On Nov 10, 8:43 am, ara.t.how...@noaa.gov wrote:
> On Fri, 10 Nov 2006, darenb...@gmail.com wrote:
> > I'm writing a web service that accepts a call to initiate a few
> > self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> > can't seem to find any documentation on how I could kick off the
> > scripts without having the parent script wait on them to complete.
> > Obviously, I don't need arguments our output back from the scripts, so
> > all I'm concerned with is that they start and the parent can end
> > without killing them.
>
> > What's the best way to do this?by far the simplest is
>
> system "in_the_background &"
>
> -a
> --
> my religion is very simple. my religion is kindness. -- the dalai lama

Ara.T.Howard

11/10/2006 3:43:00 PM

0

David Vallner

11/11/2006 1:06:00 PM

0

Farrel Lifson wrote:
> On 10/11/06, darenbell@gmail.com <darenbell@gmail.com> wrote:
>> I'm writing a web service that accepts a call to initiate a few
>> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
>> can't seem to find any documentation on how I could kick off the
>> scripts without having the parent script wait on them to complete.
>> Obviously, I don't need arguments our output back from the scripts, so
>> all I'm concerned with is that they start and the parent can end
>> without killing them.
>>
>> What's the best way to do this?
>>
>>
>>
>
> You could just use ruby threads?
>

If the scripts do anything with standard input, they could hijack the
Ruby script's from the thread. Use popen, or the open('|some-script')
form instead of system?

David Vallner

darenbell@gmail.com

11/13/2006 1:53:00 PM

0

Sorry for not responding sooner, but I was out of my office since my
last response. David's solution worked perfectly. Thanks for the help
everyone.

On Nov 11, 7:06 am, David Vallner <d...@vallner.net> wrote:
> Farrel Lifson wrote:
> > On 10/11/06, darenb...@gmail.com <darenb...@gmail.com> wrote:
> >> I'm writing a web service that accepts a call to initiate a few
> >> self-contained scripts on a RHEL4 webserver. Being new to Ruby, I
> >> can't seem to find any documentation on how I could kick off the
> >> scripts without having the parent script wait on them to complete.
> >> Obviously, I don't need arguments our output back from the scripts, so
> >> all I'm concerned with is that they start and the parent can end
> >> without killing them.
>
> >> What's the best way to do this?
>
> > You could just use ruby threads?If the scripts do anything with standard input, they could hijack the
> Ruby script's from the thread. Use popen, or the open('|some-script')
> form instead of system?
>
> David Vallner
>
> signature.asc
> 1KDownload