我有这个:
$ cat waitforinput.sh
#!/bin/sh
while read line
do
echo $line
done
我这样做:
>>> p1 = subprocess.Popen("/home/abc/waitforinput.sh", shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
>>> for i in xrange(1000):
... p1.stdin.write("this is a good idea")
但是当我现在这样做时,我看不到任何输出:
>>> for i in p1.stdout:
... print i
...
我究竟做错了什么 ?