When I directly execute the script it is running (means LED turned on), but when I write script to click on button and than LED on it is not running (means LED is not turned on). I had also made this on.py file in that cgi-bin folder and give all permission to it. Here the first script is running perfectly but second is not running. Both scripts are nearly same, only difference is button code in PHP portion. Where is the problem in second script, I don't know ... Please help me! Thanks in advance!
1)index.php
<html>
<body>
<form method="POST" action="">
<p>
<input type="button" name="on" value="ON" /><br>
<input type="button" name="off" value="OFF" />
</p>
</form>
<?php
exec("sudo python /usr/lib/cgi-bin/on.py");
?>
</body>
</html>
----------------------------------
2)index.php
---------------------------------
<html>
<body>
<form method="POST" action="">
<p>
<input type="button" name="on" value="ON" /><br>
<input type="button" name="off" value="OFF" />
</p>
</form>
<?php
if ( isset( $_POST["on"] ) ) {
exec("sudo python /usr/lib/cgi-bin/on.py");
}
?>
</body>
</html>
LED Flash
'; GPIO.setmode(GPIO.BCM) GPIO.setwarnings(False) GPIO.setup(35,GPIO.OUT) #Turn LED on GPIO.output(35,GPIO.HIGH) time.sleep(1) print 'stopped by user'; print 'cleaning up GPIO pins'; print 'all done'; print ''; this is my code inside on.py file in cgi-bin folder.. – snehal desai Mar 26 '16 at 03:43