Hi All,
I have a question on this python which i have attached below. My question is i want the python script "PIRoncall.py" script to be run once but i want the read file loop to continue,currently it keeps on duplicating and there is mutiple process of "PIRoncall.py" script. I have thought of using shell command for checking process existence (pgrep?) before launching PIRoncall.py instance but i am not sure how to proceed. Anyone please help ?
I have a question on this python which i have attached below. My question is i want the python script "PIRoncall.py" script to be run once but i want the read file loop to continue,currently it keeps on duplicating and there is mutiple process of "PIRoncall.py" script. I have thought of using shell command for checking process existence (pgrep?) before launching PIRoncall.py instance but i am not sure how to proceed. Anyone please help ?
import time import subprocess import os oldline="none" while True: fh=open("status_mjpeg.txt","r") line = fh.read(5) print line fh.close() time.sleep(0.3) if oldline !=line: if line == "md_re": print "on" time.sleep(0.2) os.system(' /usr/bin/python PIRoncall.py &') time.sleep (2) elif line == "ready": print "on" os.system(' /usr/bin/python PIRoffcall.py') time.sleep(2) oldline = line