I can see the result of:
echo exec("whoami"); // will output "www-data"
however if I try to run a real world command:
echo exec("casperjs myscript.js /foo/bar");
then nothing happens:
- no output (the casperjs script should output some stdout log messages)
- no action (the script should create an image, using an absolute path, but it doesn't)
- no errors from PHP
- no output of the shell command
I've searched on StackOverflow, and went to try alternative ways (tested first in the shell, to be sure they work):
echo exec("casperjs /absolute/path/to/myscript.js");
echo exec("/usr/local/bin/casperjs /absolute/path/to/myscript.js");
I tested also other combinations, using system(), shell_exec() and even passthru()
but it's always the same thing: no error, no output, even in php log files, so it is very, very hard to understand the problem :(
www-data)? The web server might bechroot'd to a specific directory for security reasons.safe_modeenabled? This limits the directories thatexec()can run commands from.safe_modeusingphpinfo()and it is disabled (set to Off)sudo -su www-dataand it worked. By the way the script to be executed by Casper is located, and operated in a directory whose tree is owned (group) bywww-data