为什么subprocess.Popen不能与find -exec一起使用?

时间:2017-07-17 10:54:27

标签: python subprocess

我目前有以下内容:

subprocess.Popen(["find", ".", "-exec", "sh", "-c",
    "\"echo 'this will not echo'; touch testing.txt \"", ";"], shell=True)

哪个似乎不起作用(没有生成或从echo语句输出testing.txt文件)。

使用subprocess.Popen上述命令是否可以正常工作?如果是的话,我需要做一些调试......

我基本上是想跑:

find . -exec sh -c "echo 'test'; touch abcxyz" \;

1 个答案:

答案 0 :(得分:0)

通过以下方式解决:

subprocess.Popen(["find", ".", "-exec", "sh", "-c", "echo 'this will not echo'; touch testing.txt ", ";"])

已移除shell=True

相关问题