Reputation: 73
I have been looking through Google and SO for something that could help me solve this but I have run into a block. I am a bit new to Python but I am looking for a way to run multiple apps that will continuously run in the background.
For example, I need 4 apps to start up with a param -appnum set to a different value. I would like to use python to count up and then start up a new app that will continue to run.
I assumed I would use subprocess but I feel a bit overwhelmed by the documentation.
I also plan to have the app print out sequences of numbers and would like to redirect this to a file. I noticed some of the SO questions talked about this, but I am a little confused on what to do.
Upvotes: 1
Views: 532
Reputation: 992955
A simple way to start might be to use os.popen()
, like this:
import os
subprogs = [None] * 4
for i in range(4):
subprogs[i] = os.popen("app -appnum " + i, "r")
From here, you can read from each subprog[i]
just like a file, capturing the output of the app
program.
Note that although the documentation says this function has been deprecated, it still works perfectly fine for many purposes. You can explore the subprocess
module when you're more familiar with the limitations of os.popen()
.
Upvotes: 1