私はpopenのは、実行したい:Pythonのpopenのgrepが
シェルから実行grep -i --line-buffered "grave" data/*.txt
、これは私の希望の結果が得られます。私は、私はgrep
をテストする非常に同じディレクトリに、PythonのREPLを起動し、the instruction from the docsに従うなら、私はpopenのを養うために、適切な引数リストがどうあるべきか得る:
['grep', '-i', '--line-buffered', 'grave', 'data/*.txt']
p = subprocess.Popen(args)
の結果は
grep: data/*.txt: No such file or directory
と私はp = subprocess.Popen(args, shell=True)
をしようとすると、私が手:
Usage: grep [OPTION]... PATTERN [FILE]...
Try `grep --help' for more information.
指名手配のプロセスを実行する方法上の任意のヘルプ?私はMacOS Lionにいる。
+1プラットフォーム非依存 –
ありがとう。プラットフォームの独立性を高めるためには、 'data/\ *。txt'の代わりにos.path.join( 'data'、 '\ *。txt' –