How to run a shell script from rails

Hello,

I'm new for ruby on rails. I have a shell script but really don't know how to run it from rails. And after the script has been executed, how can I get the value of the variables that has been created by the script ? Thanks in advance for any help you can offer.

AP

Do a search on this group with keywords like shell, execute, system() and you will perhaps find the info you needed. On the other hand, you can give us more details what is that you try to achieve and we can try to help you more.

Try this (swapping ls for the shell script). value will be a string containing the output.

value = `ls`

-Zubin

Zubin Henner wrote:

Try this (swapping ls for the shell script). value will be a string containing the output.

value = `ls`

-Zubin

In addition to the back ticks,

If you need more fine grained control of the process (like feeding it's stdin, check out IO.popen..

If you need access to stderr, then use popen3

If you intend the process to be performing a long task asynchrously, then check out the backgroundrb gem

hth

ilan