2017-07-17 85 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

相關問題