Redirection problem.

Thaddeus L. Olczyk olczyk at
Wed Sep 13 23:34:56 CEST 2000

I'm having some problems with a simple redirection problem.
I want to write a function call it DoIt that executes a command
in a seperate process, and returns an error status when done.
I also want it to print to stdout the combination of what is written
in to stdout and stderr by the process.

For example:

if not DoIt("ls -R *"):
      print "Exited with error."
     print "Exited with Success."

When executed the output ( sans stuff after # which are my comments
here) should look like:

dir1/f1   # normal listing
dir1/f2   # normal listing
dir2: Permission denied # process doesn't have read permission on that
Exited with Success. # At least I think it should exit with success.

The problem I have is controling the two outputs, and the return code.

for example:
if I try

while 1:
   if not b:
       return sout.close()

The problem is squeazing at three conditions in.

More information about the Python-list mailing list