So i'm working on a project trying to turn on/off the light in my room using a webpage. I've created this python script which reads a file to get the state of the light(on or of) and then writes the 'opposite' back to the file.(this would basically toggle the light) If i now call this script in php with
system("python script.py")
it doesn't output anything to the page instead of the expected state(on or of)
f = open("lightState.txt", "r")
var = f.read(2)
f.close()
f = open("lightState.txt", "w")
state = ""
if(var == "of"):
#turn light on
state ="on"
if(var == "on"):
#turn light off
state = "of"
print(state)
f.write(state)
f.close()
i've also tried this with another python script in the same folder which worked perfectly fine.
Any help is apreciated
-SmRndmGy