Hello everyone, i'm looking for a way in python to run an external binary and watch it's output for: "up to date" If "up to date" isn't returned i want to run the original command again, once "up to date" is displayed i would like to be able to run another script. So far I've figured out how to run the binary with options using subprocess but thats as far as I've gotten. Thanks!
views:
47answers:
1
+2
A:
Use Popen from subprocess like this
process = Popen("cmd", shell=True, bufsize=bufsize, stdout=PIPE)
Then use process.stdout to read from program's stdout (like reading from any other file like object).
Ivan
2010-05-19 09:36:03
Thank you very much for the reply! So far i've managed to come up with this: http://pastebin.com/1GNAZ5bBBut im unsure how to re-run if HLDS is not found, or how to call a new binary if it is?
bleomycin
2010-05-19 10:44:44
Can't access your pastebin currently. But I'll try to answer. Each instance of POpen represents one process. So to start it again you have to create a new instance of POpen and repeat the process.
Ivan
2010-05-19 11:43:23