Reputation: 1
I'm running a wget
in Python via os.system
.
Is there anyways to hide the output? I tried
> /dev/null
and tried running the command with a $
in front of it.
Upvotes: 0
Views: 101
Reputation: 2106
Use the subprocess module instead.
Using subprocess.call
(which is a helper function for some more advanced subprocess features), you can redirect stdout and stderr to file objects. If you open /dev/null
(the os module has os.devnull
which is a platform-independant path of the null device that can help), you can hand it to subprocess.call and suppress all output
import os
import subprocess
devnull = open(os.devnull, 'w')
subprocess.call([...], stdout=devnull, stderr=devnull)
Upvotes: 1