get the output of a cmd via popen2

Rajarshi Guha rajarshi at
Sun Aug 26 02:18:17 CEST 2001

  I think I'm doing the right thing, but it does'nt seem to be working.

I have a command which I want to run from a Python script and I want to 
capture the output. So I do,

i,o = os.popen2(cmd)

where cmd is the string that represents the command. But on printing o all 
I get is an object representation like: 

<open file '(fdopen)', mode 'r' at 0x810d9f8>

Not the output of the program.

Any suggestions as to whats going wrong and how to fix it?

Rajarshi Guha

More information about the Python-list mailing list