Home     My Faqts     Contributors     About     Help    

faqts : Computers : Programming : Languages : Python

FAQTs repaired & updated!
Thanks for your patience...
Entry Add Entry Alert - Edit this Entry

Did You Find This Entry Useful?

13 of 19 people (68%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Is there any way to shell out to a program and return whatever is printed to stdout rather than the exit status?

Jul 23rd, 2000 23:01

unknown unknown, Michael Hudson, Loren Poulsen
Mark Hammond

import commands
print commands.__doc__
Use os.popen() - RTFM.  However, note that for Python 1.5.2 and before,
os.popen often doesnt work on Windows - you need my win32 extensions for
this, where win32pipe.popen() does the right thing.  os.popen should
reliably work on Windows in Python 2.0 and later.

© 1999-2004 Synop Pty Ltd