I'm trying to write some short script in python which would start another python code in subprocess if is not already started else terminate terminal & app (Linux). I'm trying to python Write some short scripts in , If not already started , It will start another in the child process python Code , Otherwise, terminate the terminal and application (Linux).
So it looks like: So it looks like :
#!/usr/bin/pythonfrom subprocess import Popentext_file = open(".proc", "rb")dat = text_file.read()text_file.close()def do(dat): text_file = open(".proc", "w") p = None if dat == "x" : p = Popen('python StripCore.py', shell=True) text_file.write( str( p.pid ) ) else : text_file.write( "x" ) p = # Assign process by pid / pid from int( dat ) p.terminate() text_file.close()do( dat )
Have problem of lacking knowledge to name proces by pid which app reads from file ".proc" . There is a lack of access through the application from the file “.proc” Read the pid The problem of naming process knowledge .The other problem is that interpreter says that string named dat is not equal to "x" ??? Another problem is that the interpreter says it's called dat Of The string is not equal to "x" ???What I've missed ? What I missed ?