Python subprocess.Popen()失败

时间:2017-10-17 01:32:26

标签: python

我正在尝试执行此命令,但它失败了:

cmdp = ("ps --ppid 1 -f | grep interactive > test.out")
sp = subprocess.Popen(cmdp, shell = True, stdout=subprocess.PIPE, 
        stderr=subprocess.PIPE)
name, err = sp.communicate()
rc = sp.wait()

rc以 1 的形式返回,并且未创建test.out

如果我在终端中运行ps --ppid 1 -f | grep interactive > test.out,它就可以正常工作并创建test.out

0 个答案:

没有答案