php is not executing bash commands
Posted: Sun May 01, 2016 10:52 am
Hi Guys
I am running apache server on Pi.
The server running correctly I can access standard apache site localhost and inside the network by 192.168.0.X
I have published fallowing site in path /var/www/html/lamp/index.html
which should allow be execute scripts:
The site display correctly but don`t execute commands.
I have also add fallowing lines to sudoers file
sudo nano /etc/sudoers
Any idea what I am missing, because when I am pressing the "turn on" the system don`t execute the python script?
I am running apache server on Pi.
The server running correctly I can access standard apache site localhost and inside the network by 192.168.0.X
I have published fallowing site in path /var/www/html/lamp/index.html
which should allow be execute scripts:
Code: Select all
<html>
<head>
<meta charset="UTF-8" />
</head>
<?php
if (isset($_POST['ON']))
{
exec("sudo python /home/pi/Pimoroni/unicornhat/rainbow.py");
}
if (isset($_POST['OFF']))
{
exec("here will be command which terminate the script");
}
?>
<form method="post">
<button name="ON">turn On</button>
<button name="OFF">turn Off</button><br>
</form>
</html>
I have also add fallowing lines to sudoers file
sudo nano /etc/sudoers
Code: Select all
www-data ALL=(ALL) NOPASSWD: ALL
www-data ALL=NOPASSWD: /home/pi/Pimoroni/unicornhat/