2017-07-17 6 views
0

私は現在、次のようにありますsubprocess.Popenがfind -execで動作しないのはなぜですか?

(なしtesting.txtファイルはecho文から生成されていないか、出力された)仕事には表示されません
subprocess.Popen(["find", ".", "-exec", "sh", "-c", 
    "\"echo 'this will not echo'; touch testing.txt \"", ";"], shell=True) 

上記のコマンドは実際に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; はシェルで動作しますか? –

答えて

0

shell=Trueを削除

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

もしそうなら、私は基本的に実行しようとしている...いくつかのデバッグを行うために

が必要になります。

関連する問題