a popen question. Please help

ivanko.rus at gmail.com ivanko.rus at gmail.com
Sun Aug 30 20:13:12 CEST 2009

First, I think you should use subprocess.Popen (it's recommended by  
PEP-324) instead of os.popen. For example:

p = subprocess.Popen(["top"], stdout = PIPE)

And to write to stdin (in your case "q") you can use p.stdin.write("q"), or  
terminate the process with p.terminate(), or just specify the -n option  
(the number of iterations) to the value you desire. It's done in that way:  
subprocess.Popen(["top","-n 1"], stdout=PIPE)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090830/d926e210/attachment.html>

More information about the Python-list mailing list