我对蟒蛇有点陌生。目标是使用子进程parse&;从shell检索打印输出。执行错误如下面的示例输出消息所示。下面还显示了示例代码片段
代码段:
testStr = "cat tst.txt | grep Location | sed -e /.*Location: //g "
print "testStr = "+testStr
testStrOut = subprocess.Popen([testStr],shell=True,stdout=subprocess.PIPE).communicate()[0]
输出:
testStr = cat tst.txt | grep Location | sed -e /.*Location: //g
cat: tst.txt: No such file or directory
sed: -e expression #1, char 15: unknown command: `/
是否有可以使用的变通方法或功能?
Appreciate your help Thanks