php cannot call python

General Tech Bugs & Fixes 2 years ago

0 1 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (1)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

 

When I call a simple python-script that blinks LED once, from a PHP-script via browser, nothing happens.

and I add these lines in the sudoers file.

apache ALL=(ALL) NOPASSWD: ALL
apache2 ALL=(ALL) NOPASSWD: ALL
www-data ALL=(ALL) NOPASSWD: ALL
adm ALL=(ALL) NOPASSWD: ALL

/var/www/html owner&Group is www-data and python script owner&Group is www-data also

what is the problem?



php
if (isset($_POST['RedON']))
{
exec('sudo python /var/www/html/xbee.py');
}
if (isset($_POST['RedOFF']))
{
exec('sudo python /home/pi/xbee2.py');
}
if (isset($_POST['YellowON']))
{
exec('sudo python /var/www/html/xbee2.py');
}
if (isset($_POST['YellowOFF']))
{
exec('sudo python /var/www/gpio/yellow_off.py');
}
if (isset($_POST['GreenON']))
{
exec('sudo python /var/www/gpio/green_on.py');
}
if (isset($_POST['GreenOFF']))
{
exec('sudo python /var/www/gpio/green_off.py');
}
?>

  <title>title>


 method="post">
  
 style="width: 75%; text-align: left; margin-left: auto; margin-right: auto;"
 border="0" cellpadding="2" cellspacing="2">
    
      
         style="text-align: center;">Turn LED on
         style="text-align: center;">Turn LED off
  
  
     style="text-align: center;"> name="RedON">Red On
     style="text-align: center;"> name="RedOFF">
                                                
                                                
0 views
0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.