[Tutor] Subprocess Stdout Redirection
mammar at gmail.com
Sat Feb 6 19:48:49 CET 2010
Hope you will be fine and good.
Following is a snippet of python code i am using for a regression testing.
def StartProc(dir, parm):
proc_log = open(dir + os.sep + "MyLog.txt","w") #new path for each file
proc = subprocess.Popen(path, 0, None, subprocess.PIPE, proc_log, None)
MyReset(proc) #reset the process(proc) to
its default values
proc.stdout = proc_log #no effect
print "fptr ", proc.stdout
prm = True
for i in range(0, 5):
prm = False
What I want to do is to start an executable only once, but on each iteration
I want to redirect the process output to a different file. What is
happening, is that files are created in the different path, but output is
redirected to the file that is created first time.
Note: MyReset() initializes the process (executable) to its default values
after the first iteration.
Will the following line change the process stdout to new file?
proc.stdout = proc_log
If no, than can you kindly guide me to the right way
Note: In the StartProc() if i create a new process everytime
**StartProc**() is called. Output is correctly redirected to proper file.*
Waiting for you kind reply.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor