I am trying to run multiple python programs in sequence and I want to capture the stdout or the output of each process in a file or files using tempfile or (if there is a better way to do that will be awesome). The output which will be file or multiple files generated from process 1 will be used as input for the next process. How to do that?
So my code is something like this:
# multiple files
for file in files:
P1 = Popen('python Prog1.py' + ' ' + file, stdout=PIPE , stderr=STDOUT,shell=True)
# Now I want to capture the output to files so can be used for the next process
# It didn't work
l_out_files.append(P1.stdout)
# Prog2 require if the input file is more than one to have them separated by space
P2 = Popen('python Prog2.py' + ' ' + ' '.join( l_out_files), stdout=PIPE , stderr=STDOUT,shell=True)
Thanks a lot guys,
Best