Answer the question
In order to leave comments, you need to log in
How to execute a Python script from PHP that writes to system files?
Good afternoon, dear colleagues.
I'm trying to make a page for changing network settings on RaspberryPI.
Created a script that writes settings to the dhcpcd.conf configuration:
if len (sys.argv) == 2:
with open('/etc/dhcpcd.conf', 'a') as file:
file.write(sys.argv[1])
$command = escapeshellcmd('/usr/bin/python3 /var/www/html/assets/modules/test.py 764');
system($command);
Answer the question
In order to leave comments, you need to log in
Use the sudo mechanism. If pi can write to dhcpcd.conf then give www-data permission to run /usr/bin/python3 as user pi without a password.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question