2017-07-17 80 views
0

目前,我有以下几点:为什么subprocess.Popen不能与find -exec一起使用?

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

这似乎并没有工作(不产生testing.txt文件或从echo语句输出)。

上述命令是否可以正常使用subprocess.Popen?我需要若然做一些调试...

我基本上是试图运行:

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

你想做什么? –

+0

如果您在'Popen'调用中添加'shell = True',它会起作用吗?或者,也许这足以在最后删除分号。 –

+0

命令 是否找到one_directory -type f -iname'* .json'-exec sh -c sed's/\\\\/\\\\\\\\/g'{} >> import.json; echo''>> import.json; 在shell中工作? –

回答

0

要解决它:

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

删除shell=True

相关问题