Quick Question about Linux command from Controller

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.

Hi Joe --

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?

I'm not David, but one obvious answer is use an absolute path, e.g.

    @the_site.whois = `/usr/bin/whois #{@site.domain}`

FWIW,

Do 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.

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).

Hi --