Good morning, I am trying to execute a linux command from inside my controller. It works on my development machine, but does not work in production. Here is the code. def get_whois @the_site = Site.find_by_id(params[:id]) unless @the_site flash[:error] = "Site could not be found" redirect_to :action => :index and return end @the_site.whois = `whois #{@site.domain}` @the_site.save flash[:notice] = "WHOIS information captured" redirect_to :action => :show, :id => @the_site.id end Does anyone know why this doesn''t work in production mode? It works fine in development... Any advice is appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David A. Black
2008-Jul-23 15:44 UTC
Re: Quick Question about Linux command from Controller
Hi Joe -- On Wed, 23 Jul 2008, Joe Peck wrote:> > Good morning, > > I am trying to execute a linux command from inside my controller. It > works on my development machine, but does not work in production. Here > is the code. > > def get_whois > @the_site = Site.find_by_id(params[:id]) > unless @the_site > flash[:error] = "Site could not be found" > redirect_to :action => :index and return > end > @the_site.whois = `whois #{@site.domain}` > @the_site.save > flash[:notice] = "WHOIS information captured" > redirect_to :action => :show, :id => @the_site.id > end > > Does anyone know why this doesn''t work in production mode? It works > fine in development...I suspect it''s very unlikely that this is the issue but the first thing that popped into my head was whether it''s running as a different user in production, with a different path. David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> I suspect it''s very unlikely that this is the issue but the first > thing that popped into my head was whether it''s running as a different > user in production, with a different path. > > > David >Hey David -- Hmm... if that was the problem, then how should I change it so it works? What else could be causing it to work in development, but not production? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hassan Schroeder
2008-Jul-23 16:32 UTC
Re: Quick Question about Linux command from Controller
On Wed, Jul 23, 2008 at 8:52 AM, Joe Peck <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hmm... if that was the problem, then how should I change it so it works?I''m not David, but one obvious answer is use an absolute path, e.g. @the_site.whois = `/usr/bin/whois #{@site.domain}` FWIW, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, 23 Jul 2008, Joe Peck wrote:> I am trying to execute a linux command from inside my controller. It > works on my development machine, but does not work in production. Here > is the code. > > def get_whois > @the_site = Site.find_by_id(params[:id]) > unless @the_site > flash[:error] = "Site could not be found" > redirect_to :action => :index and return > end > @the_site.whois = `whois #{@site.domain}` > @the_site.save > flash[:notice] = "WHOIS information captured" > redirect_to :action => :show, :id => @the_site.id > endDo you get an error? What is the error? Does the production machine even have that command available? Since whois connects to external servers, do you know if that connection is allowed (i.e. is there a firewall or some other network filtering going in?). Lots of variables. Need more data. -- A --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Man I feel dumb. I wasn''t getting any error I could see, but it became clear as day once I sshed onto the live server. It turns out WHOIS wasn''t installed on the Ubuntu server. So I just did: sudo apt-get install whois I love how the weirdest problems have such simple solutions (sometimes). -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
David A. Black
2008-Jul-24 19:42 UTC
Re: Quick Question about Linux command from Controller
Hi -- On Thu, 24 Jul 2008, Joe Peck wrote:> > Man I feel dumb. I wasn''t getting any error I could see, but it became > clear as day once I sshed onto the live server. > > It turns out WHOIS wasn''t installed on the Ubuntu server. > > So I just did: > sudo apt-get install whois > > I love how the weirdest problems have such simple solutions (sometimes).Well, I guess I was right that it wasn''t in the program''s path :-) David -- Rails training from David A. Black and Ruby Power and Light: Intro to Ruby on Rails July 21-24 Edison, NJ * Advancing With Rails August 18-21 Edison, NJ * Co-taught by D.A. Black and Erik Kastner See http://www.rubypal.com for details and updates! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---