Reputation: 3420
I am running a shell command in a python script which installs ruby and rubygems using the subprocess function:
subprocess.call("yum install ruby rubygems -y 2>&1", shell=True)
In this however, the 2>&1
doesn't seem to suppress the output like in a normal bash script. Is there any other way to suppress the output?
Upvotes: 1
Views: 897
Reputation: 529
You forgot this:
1>/dev/null
So, the result script will be:
subprocess.call("yum install ruby rubygems -y 2>&1 1>/dev/null", shell=True)
Upvotes: 2
Reputation: 28390
If you really need to do this then - Use subprocess.Popen
with stdout and stderr redirected to pipes.
Upvotes: 1