I am running a PHP document on an Apache server on my Raspberry Pi and I want it to run a file when a button is clicked. I put some echo commands under the command to make t
as you said you are running it like apache->php->shell_exec(SUDO..)
So the apache user has to be in sudoers file, better you don't give sudo to apache instead give apache (www-data) user right to run your python program
put first line in your python script: #!/usr/bin/env python
so the script knows which program to open it with..
then
change group:
chgrp www-data /path/to/python-script.py
make it executabel
chmod +x /path/to/python-script.py
try it
shell_exec("/path/to/python-script.py");
I hope it works ;)
TIPP: Apache and PHP are for delivering Documents and Strings
, if you want some kind of control and an API start with nodejs and https://www.npmjs.com/package/rpi-gpio package. This way you will have one place for your solid automation environment