newbie question - executing system commands

Donn Cave donn at
Tue Sep 4 19:13:45 CEST 2001

Quoth TerryByrne1963 at (Terry Byrne):
| I've had good luck with this combo...
|     cmdPipe = os.popen(aCmdLine)
|     resultStream =
| At this point you can look through resultStream for any error codes
| that may have been returned by the command line process. Good luck!

You can look, but unless you made special provisions for it in aCmdLine,
you won't find them.  On UNIX, diagnostic and error output will go to a
separate output stream, probably already open on the tty.  If you want
them in the popen pipe (and you probably don't want them!), you can
probably get them with a "2>&1" in the command line - that reopens the
diagnostic output on the same stream as standard output, which has already
been opened on the popen pipe.  (1 == standard output, 2 == error output,
>& == dup2().)

	Donn Cave, donn at

More information about the Python-list mailing list