2009/6/16 Pasi <
pasi.t...@nsn.com>:
Hi,
The Popen.communicate can be used to give only one value. It cannot be
used interactively. One option is to use stdin.write() and
stdout.read() methods. See example below:
import subprocess
process = subprocess.Popen(["test.bat"], stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
process.stdin.write('N')
out = ''
while not 'REBOOT[Y,N]?' in out:
out += process.stdout.read(1)
print out,
process.stdin.write('N')
print process.stdout.read()
Br,
Juha