Redirect stderr

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


I wish to do this:

#!/usr/bin/python

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.

Thanks,
-- 
David N. Welton, Web Engineer, Linuxcare, Inc.
415.354.4878 x241 tel, 415.701.7457 fax
dwelton at linuxcare.com, http://www.linuxcare.com/
Linuxcare. At the center of Linux.




More information about the Python-list mailing list