I have this but the subprocess reading from pipe at the end hangs:
$cat waitforinput.sh
#!/bin/sh
while read line
do
echo $line
done
>>> p1 = subprocess.Popen(["/home/abc/waitforinput.sh", "-v"], shell=True, executable=None,stdin=subprocess.PIPE, stdout=subprocess.PIPE)
>>>
>>>
>>> p1.stdin.write('This is a good idea\n')
>>> p1.stdin.write('This is a good idea\n')
>>> p1.stdin.write('This is a good idea\n')
>>> p1.stdin.write('This is a good idea\n')
>>> p1.stdin.write('This is a good idea\n')
>>>
>>>
>>> p1.stdin.flush()
>>>
>>> for i in p1.stdout:
... print i
...
What should I do so that it does not hang?