开发者

call external program in python, watch output for specific text then take action

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 ru开发者_如何学编程n the binary with options using subprocess but thats as far as I've gotten. Thanks!


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜