2017-07-18 21 views
0
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testFirst", ";"]) 
subprocess.call(["find", ".", "-exec", "sh", "-c", "echo testSecond", ";"], shell=True) 
subprocess.call(["find . -exec sh -c 'echo testThird' \\;"], shell=True) 

subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testFirst", ";"]) 
subprocess.call(["find", ".", "-exec", "sh", "-c", "touch testSecond", ";"], shell=True) 
subprocess.call(["find . -exec sh -c 'touch testThird' \\;"], shell=True) 

次の出力:奇妙なサブプロセスの振る舞い

testFirst 
testFirst 
testFirst 
. 
./test.py 
./data 
testThird 
testThird 
testThird 
. 
./test.py 
./testFirst 
./data 

そしてだけtestFirsttestThirdファイルが作成されます。

動作の説明は何ですか?

私は、出力がtestFirst,testSecond,testThirdと3つのファイルが作成されていると仮定します。

+0

? –

+0

これは私の実際のコードではありません。問題を示すために絞り込んだところです。 –

答えて

0

https://stackoverflow.com/a/10661488/1663462

あなたは真のシェルを=渡すと、popenのは、単一の文字列引数ではなく、 リストを期待しています。あなたが最初の4つの引数を必要としないのはなぜ

...........