i'm running Nginx on my Raspberry PI with PHP 5.4.14 (fpm-fcgi). It all works well. But in one script i make a shell call using shell_exec.
echo shell_exec("sudo python " . $file);
it works well if i use the console with
php test.php
but if i use the browser to call this file the php-file will be executed but i don't get any output by the shell_exec (not even an error message).
So i hope you could help me fix this problem.
The called python file makes use of the GPIO so sudo is required, right?
Here is my python code:
#!/usr/bin/env python
try:
import RPi.GPIO as GPIO
except RuntimeError:
print "Error Importing GPIO. Did your forgot the superuser privilieges?"
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(3, GPIO.OUT)
GPIO.output(3, not GPIO.input(3))
print "New LED state is: ", GPIO.input(3)
#GPIO.cleanup()