3

I cannot at all execute a python script via php exec. This is my code

<?php
$output = shell_exec("python /var/www/html/socket/power_on.py");

$output = shell_exec("sudo python /var/www/html/socket/power_on.py");

$output = shell_exec("/usr/bin/python /var/www/html/socket/power_on.py");
echo $output;
?>

I've tried all of the above yet no luck the only command that seems to work that I've also tried is 'ls' How to I give the user www-data access to sudo, as that may work. Since I've tried chmod 777 on the directory and file still no luck

12
  • shell_exec() was disabled ? plothost.com/kb/… Commented Jan 21, 2018 at 8:26
  • echo($output); ? Commented Jan 21, 2018 at 8:26
  • If that was the case, why would the ls command work via shell_exec Commented Jan 21, 2018 at 8:26
  • Aw, sorry. didn't note that. Commented Jan 21, 2018 at 8:28
  • Seems duplicate of this stackoverflow.com/questions/18721066/… Commented Jan 21, 2018 at 8:30

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.