I have a small command line tool that reads from stdin. On the command line, I would run ...
./foo < bar
or...
cat bar | ./foo
With gziped file I can run
zcat bar.gz | ./foo
in Python I can do ...
Popen(["./foo", ], stdin=open('bar'), stdout=PIPE, stderr=PIPE)
but i can't do
import gzip Popen(["./foo", ], stdin=gzip.open('bar'), stdout=PIPE, stderr=PIPE)
I need to run
p0 = Popen(["zcat", "bar"], stdout=PIPE, stderr=PIPE) Popen(["./foo", ], stdin=p0.stdout, stdout=PIPE, stderr=PIPE)
Am I doing something wrong? Why can't I use gzip.open ('bar') as the stdin argument for Popen?
python scripting subprocess
eric.frederich
source share