Redirecting stdin/stdout/setderr and os.execv

Richard Philips Richard.Philips at ua.ac.be
Wed Jan 16 10:25:20 EST 2002


How do I redirect stdin, stdout en stderr from within a python script 
together with os.execv:


import os
import sys

sys.stdout = open("/tmp/output","wb")
os.execv("/bin/ls", ["ls", "-ls"])


does not redirect the stdout of the /bin/ls

Any ideas on this ?

I am looking for a replacement for os.system which is independent of the 
pecularities of the shell in use.

Thank you,


Richard




More information about the Python-list mailing list