Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


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

Rep: Reputation: Disabled
command execution problem

I have a 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 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, 09:41 AM   #2
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,707

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
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, 03:29 PM   #3
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);


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 07:31 AM
Only execute 2nd command on successufl execution of 1st command kregec05 Linux - Newbie 3 08-19-2009 10:29 AM
php command execution problem avswamy Programming 3 01-31-2005 04:55 AM
command execution leonidas Linux - General 1 09-22-2004 12:29 AM
could not open session problem in linux during su - command execution selvaraju Linux - Security 2 08-21-2004 11:24 AM > Forums > Linux Forums > Linux - Newbie

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

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