redirecting stderr back..

rh0dium steven.klass at gmail.com
Fri Jan 9 23:30:30 CET 2009


Hi All,

Can someone tell me how to redirect stderr back to the console once
you've moved it?

import os,sys
se = os.open("/tmp/mod.log", os.O_WRONLY|os.O_APPEND|os.O_CREAT)
sys.stderr.write("Foobar\n")
Foobar
os.dup2(se, 2)

cmds = os.popen("ls alaksjdf")

<Now what do I need to do here to make this come back?>

sys.stderr.write("Foobar\n")
Foobar

Any ideas?  Thanks






More information about the Python-list mailing list