Usually I can change stdout in Python by changing the value of sys.stdout
. However, this only seems to affect print
statements. So, is there any way I can suppress the output (to the console), of a program that is run via the os.system()
command in Python?
On a unix system, you can redirect stderr and stdout to /dev/null as part of the command itself.
os.system(cmd + "> /dev/null 2>&1")