Redirect output of Python program to /dev/null

Posted by STM on Server Fault See other posts from Server Fault or by STM
Published on 2010-06-08T16:09:04Z Indexed on 2010/06/08 16:12 UTC
Read the original article Hit count: 345

Filed under:
|
|
|
|

I have a Python executable, written and compiled by somebody else, that I simply need to run once halfway down my own bash script. The program uses a text-based UI, therefore waits for input before proceeding, but the key operations it performs when starting are required in my bash script. A messy (and strange) procedure I know, but unfortunately I haven't got any other options.

I've gotten around forcefully closing the program with a kill signal, but the program's TUI insists on outputting to wherever it's run. I've tried redirecting both stdout and stderr to /dev/null and running the program in the background by suffixing an ampersand, but simply can't get it to play ball. I believe the cause is the program spawns other processes, and the output redirection of the parent process doesn't affect them. Is there any trick I can utilise to redirect all output from child processes too?

© Server Fault or respective owner

Related posts about linux

Related posts about bash