[Ruby] Launching script/runner from within Rails

Eric Hodel drbrain at segment7.net
Thu Feb 8 12:09:19 PST 2007


On Feb 8, 2007, at 11:58, ben wiseley wrote:
> On 2/8/07, Dan Harms <zintavision at gmail.com> wrote:
>> Is it possible to launch a process ala script/runner from within
>> Rails?  Or
>> any other way to launch multiple background threads.  Yes, I know
>> BackgroundRb is a possibility, just wondering what other options  
>> are out
>> there.
> You can shell out using the ` (tick under the tilde key)
>
> we use this to validate image file formats... like so:
>
>     file_formats = ["JPEG","PNG","GIF","TIFF","PC bitmap"]
>     res = `file #{filename}`
>     file_formats.each do |ff|
>       if res.include?(ff)
>         return
>       end
>     end
>
> so you should be able to use that on script runner type stuff.
>
> This isn't async though - which is what you need, right?  Fire and  
> forget?

For fire and forget, fork and exec:

fork do
   exec 'your command here'
end


More information about the Ruby mailing list