Cannot execute python script from php -


i on raspberry pi. permissions of files including python script looks this:

#!/usr/bin/python time import sleep import rpi.gpio gpio gpio.setmode(gpio.board) gpio.setup(11, gpio.out) gpio.output(11, false) sleep(0.4) gpio.output(11, true) sleep(1.6) gpio.output(11, false) sleep(1) 

is owned www-data , files set 777 (yes, know not smart i'm trying fix this.) run using sudo , visudo file here:

www-data all=(all) nopasswd: /var/www/gateopener.py /usr/bin/python /bin/chmod 

and here php...

<?php if (($_post["safe2"]) != "good") {     header("location: http://xx.xxx.xx.xxx/index.html"); } ignore_user_abort(true); set_time_limit(0); `/usr/bin/sudo /var/www/gateopener.py`; ?> 

now tell me why hell isn't working? have tried different variations of (ei moving file around, using different permissions.). have tried using php's exec() function well...help me please.

run_me_as_daemon.py

#!/usr/bin/python time import sleep import rpi.gpio gpio import os while true:    if not os.path.exists("open_gate.txt"):continue    os.remove("open_gate.txt")   # file delete !!! dont re-enter    open("log.txt","w") f:      print >>f,"opening gate @ %s"%(time.strftime("%x %x"),)      gpio.setmode(gpio.board)      print >>f, "set mode %s"%(gpio.board,)      gpio.setup(11, gpio.out)      print >>f, "set 11 %s"%(gpio.out)       gpio.output(11, false)      print >> f,"output low signal 11"      sleep(0.4)      gpio.output(11, true)      print >> f,"output high signal 11"      sleep(1.6)      gpio.output(11, false)      print >> f,"output low signal 11"      sleep(1)      print >> f,"competed task" 

index.php

<?php if (($_post["safe2"]) != "good") {     header("location: http://xx.xxx.xx.xxx/index.html"); } file_put_contents("open_gate.txt"," "); ?> 

is 1 possible solution


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -