rajpython
rajpython

Reputation: 179

stdout of a process to a file in python

I am working on the integration of two different processes into a single process, but i required to print the stdout of each process separately into two different files. (possibly to a tkinter gui).

say process1 to file1 and process2 to file2. Any suggestions?

Upvotes: 0

Views: 44

Answers (1)

mgilson
mgilson

Reputation: 310287

Python's subprocess will do this just fine ...

with open('process1.stdout', 'wb') as f1:
    p1 = subprocess.Popen(['process1'], stdout=f1)
with open('process2.stdout', 'wb') as f2:
    p2 = subprocess.Popen(['process2'], stdout=f2)

Upvotes: 2

Related Questions