Possible Duplicates:
How to get output from subprocess.Popen()
Retrieving the output of subprocess.call()
Here is my question. I have an executable called device_console. The device_console provides a command line interface to a device. In device_console, four commands can be run: status, list, clear and exit. Each command produces an output. As an example:
[asdfgf@localhost ~]$ device_console
device_console> list
File A
File B
device_console> status
Status: OK
device_console> clear
All files cleared
device_console> list
device_console> exit
[asdfgf@localhost ~]$
As part of testing, I want to get the output of each command. I want to use Python for it. I am looking at Python's subprocess, but somehow I am unable to put them together. Can you please help?