I have been (unsuccessfully) trying to use Python's subprocess
module to interact with an executable program. The program is a very simple command line based script.
It basically just acts in the following way: prompt user with text, wait for numeric input, prompt with more text, wait for next input, etc.
So I set up the subprocess like so
from subprocess import Popen, PIPE
p = Popen('filename.exe', stdin=PIPE, stdout=PIPE)
Then I get the first prompt
print p.stdout.readline()
Properly returns
Enter some value blah blah
Great! Then I try to enter the desired value
p.stdin.write('10.0')
It then completely hangs. I can try grabbing the next prompt
print p.stdout.readline()
but it still hangs no matter what.
What is the proper way to do this one line read/write business? I must be messing up the write
line I think.