newbie question - executing system commands

Donn Cave donn at u.washington.edu
Tue Sep 4 15:00:47 EDT 2001


Quoth Ignacio Vazquez-Abrams <ignacio at openservices.net>:
| On 4 Sep 2001, Donn Cave wrote:
|
|> 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().)

| Ugh. If you're going to do that, then you're probably better using
| os.popen4().

Same difference.  Either could be better depending on the circumstances.
My point is, without that redirection, you don't get error output in
popen().  And that's usually good.  That's also the real difference
between os.listdir() and os.popen('ls') - the former can raise an
exception where the latter will just return no results.

	Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list