I’m writing a python program that will spawn a subprocess to basically clone a log file. I have working code in 2.7, but because of vendor restrictions, I am forced to use Python 2.3, so using the subprocess module is out of the question.
I need help translating this:
self.FILE_OUT = open(self.file2write,"a" )
self.FILE_IN=subprocess.Popen( self.file2process,
stdout=self.FILE_OUT,
bufsize=0,
shell=True)
into 2.3 code.
I’m confused as to how to do the stdout=self.FILE_OUT.
It depends on what you’re doing, but the old way of executing commands was to use
os.popen. It works like this:There are other versions of
popenin theosmodule that do things like return a 2-tuple containingstdinandstdout, or a 3-tuple containingstdin,stdout, andstderr. See the docs for more details, and let me know if this doesn’t help.Here’s an example of how to use
popen2: