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)
p.stdout.readlines()

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)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to