Hi All, I have a ruby on rails application and in the controller, I try to run a shell script using exec command like this --- variable = 'sh /home/abc.sh' exec variable --- But when the control comes at this line, the mongrel server immediately crashes, and when I check its status its says "missing pid file". The shell script contains nothing wrong, it works fine on the linux console, I have also commented everything in that shell script and put just a single variable declaration, but even then the serer crashes.. Any Ideas, or is there any other way to run a shell script using ruby on rails ?? Thanks in advance.. Tahir Rauf
on 2009-06-11 08:56
on 2009-06-11 09:26
On Thu, Jun 11, 2009 at 08:56, Tahir Rauf <lists@ruby-forum.com> wrote: > > Any Ideas, or is there any other way to run a shell script using ruby on > rails ?? > First of all, this is not a mongrel question at all, but a Ruby question, so please don't follow up here. But anyway: #exec replaces the current process and never returns and is probably not what you want to do in a controller. Have a look at http://apidock.com/ruby/Kernel/system and http://apidock.com/ruby/Kernel/%60 and http://apidock.com/ruby/IO/popen/class HTH, /David
on 2009-06-11 11:48
Got the solution, exec starts a new process so don't use it.. just use the shell command in ruby like this `sh /home/abc.sh` in the controller.. It runs fine
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.