I have a listener that says "waiting for messages..." and then runs forever waiting for messages from all sorts of programs to pass to a responder. All of this works fine when I run it from the command line, but now I want to automate it so I don't have to start all my programs separately.
I started out by just trying to get my listener to start, but it doesn't print out the "waiting for messages..." message, or anything at all, when I try to route stdout to a file.
from subprocess import Popen, PIPE with open('listenerOutput', 'w') as outfile: Popen(["python", "listener.py"], stdout = outfile) All the questions I've read so far seem to be more complex than this, but I can't even seem to make this part work. Presumably, any print statements in listener.py would show up in outfile, correct? But all I get is an empty 'listenerOutput' file. Is there some extra step to make it write to the file, or am I going about this the wrong way?
> listenerOutputwhen you're usingPopen?python listener.py > listener_out &it doesn't write to anything! I still don't know why, so instead I used python's logging class in my listener to record everything and that works. And instead of using python to launch subprocesses, I used a bash script to make things simple. Still, if anyone has an idea on what went wrong, I'm all ears :]