I had a strange problem while trying to execute python on a php server (LAMP). (safe_mode off)
if I type:
$output = shell_exec("ls -lah"); echo "<pre>$Output</pre>";
I got the result of the ls
. The same goes for $output = shell_exec("tar --version");
and other applications like gzip.
However, if I switch to any of these lines:
$output = shell_exec("python --version"); $output = shell_exec("python2.7 --version"); $output = shell_exec("/usr/bin/python --version"); $output = shell_exec("python my_script.py");
And other options of this kind, I do not get any results. The command fails, python bit code has not been created, and echo
remains valid.
I also tried the exec()
command without any success.
source share