LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-01-2014, 09:21 AM   #1
k4elo
LQ Newbie
 
Registered: Dec 2014
Posts: 4

Rep: Reputation: Disabled
command execution problem


I have a socket.io installation on my website. From one of the programs on the website, I need to execute: "node server.js" in the shell to start the socket.io server. If I try to do it from php with the exec command, the shell sees "node" and errors with no file found.

So is there a way that I can execute "node server.js" successfully from inside a shell script? php could then use exec "shell_script" with no problem.
 
Old 12-01-2014, 10:41 AM   #2
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,604

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
Depends on the distribution, the security controls, and how the shell script is written (assuming it can be executed by the web server). The usual problem is assuming the shell scripts environment is the same as an interactive environment (it isn't). Best solution is to use full pathnames for all commands. Secondarily, might try making sure the search path includes the path to the commands you want to use.

But for security purposes, don't use a shell script. It is FAR too hard to make secure.
 
Old 12-01-2014, 04:29 PM   #3
k4elo
LQ Newbie
 
Registered: Dec 2014
Posts: 4

Original Poster
Rep: Reputation: Disabled
Thanks for your response. Solved it like this: exec("/home/k4elo/bin/node /home/k4elo/public_html/server.js", $output, $retval);
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Remote command execution via SSH and newgrp command SuperMegaMau Linux - General 4 05-13-2011 08:31 AM
Only execute 2nd command on successufl execution of 1st command kregec05 Linux - Newbie 3 08-19-2009 11:29 AM
php command execution problem avswamy Programming 3 01-31-2005 05:55 AM
command execution leonidas Linux - General 1 09-22-2004 01:29 AM
could not open session problem in linux during su - command execution selvaraju Linux - Security 2 08-21-2004 12:24 PM


All times are GMT -5. The time now is 05:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration