Trying to run an external program

Stephan Kuhagen nospam at domain.tld
Thu Sep 21 00:42:38 EDT 2006


Brant Sears wrote:

> Any ideas on what I might do to troubleshoot this?

As other stated out, you are using the wrong module. Try:

>>> import os
>>> p=os.popen('dir')
>>> for l in p:
...   print l
...
--- OUTPUT OF DIR HERE ---
>>> p.close()

The return value of close is the return value of the command run. If you
need to read stdout and stderr of your command or write to its stdin, use
popen2, popen3, popen4 from the os-module.

Regards
Stephan



More information about the Python-list mailing list