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 -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Jun-11 07:13 UTC
Re: Mongrel crashes while running ''exec'' through ruby
On Jun 11, 7:54 am, Tahir Rauf <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi All, > > I have a ruby on rails application and in the controller, I try to run a > shell script using exec commandYou know that the whole point of the exec command is that it replaces the current process with what you tell it to run? You may be more interested in ``, system or things like IO.popen Fred> > 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 > -- > Posted viahttp://www.ruby-forum.com/.
Frederick Cheung wrote:> On Jun 11, 7:54�am, Tahir Rauf <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Hi All, >> >> I have a ruby on rails application and in the controller, I try to run a >> shell script using exec command > > You know that the whole point of the exec command is that it replaces > the current process with what you tell it to run? You may be more > interested in ``, system or things like IO.popen > > FredThanks Fred, As far as i know system is for windows, and Currently my application is deployed on linux. Can you tell me more about IO.popen ? I just need to run a script and want the control back to the same process.. -- Posted via http://www.ruby-forum.com/.
Frederick Cheung
2009-Jun-11 08:00 UTC
Re: Mongrel crashes while running ''exec'' through ruby
On Jun 11, 8:31 am, Tahir Rauf <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Frederick Cheung wrote: > > On Jun 11, 7:54 am, Tahir Rauf <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > >> Hi All, > > >> I have a ruby on rails application and in the controller, I try to run a > >> shell script using exec command > > > You know that the whole point of the exec command is that it replaces > > the current process with what you tell it to run? You may be more > > interested in ``, system or things like IO.popen > > > Fred > > Thanks Fred, As far as i know system is for windows, and Currently my > application is deployed on linux.That''s not true> > Can you tell me more about IO.popen ?http://www.ruby-doc.org/core/classes/IO.html#M002267 Fred> > I just need to run a script and want the control back to the same > process.. > -- > Posted viahttp://www.ruby-forum.com/.
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 Thanks Every body -- Posted via http://www.ruby-forum.com/.