'NODEJS PHP - Can't start NODEJS Script from PHP EXEC
I have a NODE.JS Script which i can start manual at the Console with
cd /home/desktop/www/www.domain.com/bot/;
node bot.js;
But when i want to do this with PHP EXEC it dont work - i tried over 2 days now with all solution on google but nothing helps.
$output = exec("cd /home/desktop/www/www.domain.com/bot/; node bot.js;");
print_r($output);
Output is always 1. There is also no error log or error message - nothing.
Regards
Thomas
Solution 1:[1]
Try to give a complete path. Make sure that the file path is correct.
$output = exec("node /home/desktop/www/www.domain.com/bot/bot.js;");
print_r($output);
Solution 2:[2]
PHP exec in windows uses CMD.exe by default. So any command must observe cmd syntax.
exec("cd /home/desktop/www/www.domain.com/bot/; node bot.js;");
to
exec("cd /home/desktop/www/www.domain.com/bot && node bot.js;");
Sure, assuming that node
is available on the path
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | rohithpoya |
Solution 2 | Jone Polvora |