execute

Execute Python script from Php

时光怂恿深爱的人放手 提交于 2019-11-26 14:08:48
问题 I have a PHP webpage on my raspberry pi with 2 buttons (on and off) The on button button redirects to On.php The off button redirects to Off.php In "/usr/lib/cgi-bin" I have a python script that I would like to execute (script.py) I can perfectly execute it from the terminal by typing cd /usr/lib/cgi-bin sudo python script.py It works if I do it from the terminal. The problem is the PHP file (On.php) in my "/var/www" folder. This is what I wrote: <?php exec('cd /usr/lib/cgi-bin'); exec('sudo