I would like to run a few python scripts(I am aware of the risks , but I HAVE to get it done)
i tried using :
echo exec('python --version ');
as well as
echo shell_exec('python --version ');
Also tried '/usr/bin/python ' instead of just python
but I dont get any output at all.
I have even added the www-data to the sudoers list, still not working.
What should I do ?
Running debian and python 2.7
It seems python --version prints version info to stderr instead of stdout for some reason, so you'll need to redirect former to latter:
exec('python --version 2>&1');
Also, note that exec's return value is just the last line of the executed command's output. If you want to catch full output from command that returns multiple lines, you'll need to provide an array as exec's second argument:
$output = array();
exec($some_command, $output);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With