1
I’m trying to call a script done in Python via browser with PHP. This script has only one command that serves to turn off my Raspberry Pi.
PHP is that way:
<?php
exec('sudo python /home/pi/Documents/Programa/Script.py');
?>
Python script:
import os
os.system('sudo shutdown -r now')
I ran the program in Python and PHP (via terminal) separately and the two are working properly. Only when I call in the browser that it does not run. I know you have to change folder and file permissions, but I don’t know exactly which directories I have to give these permissions because I’m a beginner in the world of PHP and linux. I have already searched on some other site ways to do this.
Why don’t you run "shutdown" straight from PHP? This script doesn’t even have any Python.
– jsbueno
Hello jsbueno, thank you for your reply. Do you tell me to put the "sudo shutdown -r now" command straight into php exec()? That I’ve done, it doesn’t work either.
– Q.Wesley
Shows no error message? ever seen in php or server log?
– Júlio Neto
Hi Julio Neto, thanks for the reply. I do not know where the log, I will look to see if any message appears there and I return with the reply.
– Q.Wesley