# Performing arbitrary ruby scripts from rails

**URL:** <https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983>\
**Category:** Rails\
**Created:** [November 22, 2007, 11:35am UTC](https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983 "2007-11-22T11:35:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![xgamerx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/d2c977/32.png) [@xgamerx](https://www.ruby-forum.com/u/xgamerx)\
**Post date:** [November 22, 2007, 11:35am UTC](https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983/1 "2007-11-22T11:35:09Z")

</div>

Hello,

I am developing a rails application and I have certain scripts that I  
need to have run that have nothing to do with rails and that don’t need  
to provide any feedback. Basically, I have these ‘mechanize’ scripts  
that will go out and perform some actions but they have nothing to do  
with the rails application. Right now, the user has to wait for the  
mechanize scripts to finish because I just call them as a method within  
my controller.

I don’t want to do this anymore. What is the easiest way to just start a  
standalone ruby script from my rails application. Keep in mind I don’t  
need any progress reports and I don’t need to know when it finishes. I  
just need to start the script and that’s it and let it run on its own  
seperate from rails.

How can I achieve this? I do need to pass 2 parameters (string values)  
to the script.

---

<div class="post-metadata">

**Author:** ![xgamerx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/d2c977/32.png) [@xgamerx](https://www.ruby-forum.com/u/xgamerx)\
**Post date:** [November 22, 2007, 12:21pm UTC](https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983/2 "2007-11-22T12:21:41Z")

</div>

On 22 Nov., 11:35, Nathan E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:  
[…]

> I don’t want to do this anymore. What is the easiest way to just start a  
> standalone ruby script from my rails application. Keep in mind I don’t  
> need any progress reports and I don’t need to know when it finishes. I  
> just need to start the script and that’s it and let it run on its own  
> seperate from rails.
> 
> How can I achieve this? I do need to pass 2 parameters (string values)  
> to the script.

The simplest solution might be fork and exec. Something like this  
should work on Unix/Linux, but probably not on Windows:

```
def some_rails_action
  fork {
    exec "some_sript_on_path.rb", "arg1", "arg2"
  }
  render_something
end

```

HTH,  
Stefan

---

<div class="post-metadata">

**Author:** ![xgamerx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/d2c977/32.png) [@xgamerx](https://www.ruby-forum.com/u/xgamerx)\
**Post date:** [November 22, 2007, 12:25pm UTC](https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983/3 "2007-11-22T12:25:45Z")

</div>

Forgot to mention, it would be nice if it was a cross-platform solution  
as I use windows to develop…

Stefan L. wrote:

> On 22 Nov., 11:35, Nathan E. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:  
> […]
> 
> > I don’t want to do this anymore. What is the easiest way to just start a  
> > standalone ruby script from my rails application. Keep in mind I don’t  
> > need any progress reports and I don’t need to know when it finishes. I  
> > just need to start the script and that’s it and let it run on its own  
> > seperate from rails.
> > 
> > How can I achieve this? I do need to pass 2 parameters (string values)  
> > to the script.
> 
> The simplest solution might be fork and exec. Something like this  
> should work on Unix/Linux, but probably not on Windows:
> 
> ```
> def some_rails_action
> fork {
> exec "some_sript_on_path.rb", "arg1", "arg2"
> }
> render_something
> end
> 
> ```
> 
> HTH,  
> Stefan

---

<div class="post-metadata">

**Author:** ![xgamerx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/x/d2c977/32.png) [@xgamerx](https://www.ruby-forum.com/u/xgamerx)\
**Post date:** [November 22, 2007, 2:07pm UTC](https://www.ruby-forum.com/t/performing-arbitrary-ruby-scripts-from-rails/120983/4 "2007-11-22T14:07:56Z")

</div>

Sounds like you need BackgroundDRb [http://backgroundrb.rubyforge.org/](http://backgroundrb.rubyforge.org/)

On Nov 22, 5:35 am, Nathan E. \<rails-mailing-l…@andreas-
