1

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?

4

2 回答 2

2

你忘了这个:

1>/dev/null

因此,结果脚本将是:

subprocess.call("yum install ruby rubygems -y  2>&1 1>/dev/null", shell=True)
于 2013-08-30T10:22:47.470 回答
1

如果你真的 要这样做 - 使用subprocess.Popenstdout 和 stderr 重定向到管道。

于 2013-08-30T05:17:16.530 回答