Redirect stderr

David N. Welton dwelton at
Tue Aug 10 03:54:07 CEST 1999

I wish to do this:


import sys
import os

f = open("goober", "w")

sys.stderr = f
sys.__stderr__ = f

os.execv("/bin/ls", ["/bin/ls", "sdfsdfdsfds"])

and have it dump the errors into 'goober'.  I'm having some
difficulties figuring out exactly why this isn't working, or how I
ought to be doing this.

David N. Welton, Web Engineer, Linuxcare, Inc.
415.354.4878 x241 tel, 415.701.7457 fax
dwelton at,
Linuxcare. At the center of Linux.

More information about the Python-list mailing list