Or use a wrapper script with subprocess
. I used to have a utility script somewhere which would launch a set of other commands in parallel with subprocess
and collect their output, and email it off if the return code ended up being non-zero. Unfortunately I think I left it at a previous company and no longer have a copy... Not very tricky to write something like that, though.
EDIT:
I found a spare few minutes to dig through some old backups and found the class I wrote to handle multiple concurrent subprocess invocations. The code is a little large to post in this thread, but I posted it on my wiki for anybody who's interested.
It's not particularly efficient (especially the base class behaviour of buffering all data in a simple str
object) but it should be good enough for normal purposes. Also, this bit doesn't handle the emailing and checking the return codes (although it does store the return codes in a dictionary) as those are the parts I don't have any more, but those bits are pretty easy to put in the calling code.