I've got an interactive program called my_own_exe
. First, it prints out alive
, then you input S
and then it prints out alive
again. Finally you input L
. It does some processing and exits.
However, when I call it from the following python script, the program seemed to hang after printing out the first 'alive'.
Can anyone here tell me why this is happening?
// after reading the follow ups (thank you guys), i modified the code as following:
import subprocess
import time
base_command = "./AO_FelixStrategy_UnitTest --bats 31441 --chix 12467 --enxutp 31884 --turq 26372 --symbol SOGN --target_date " + '2009-Oct-16'
print base_command
proc2 = subprocess.Popen(base_command, shell=True , stdin=subprocess.PIPE,)
time.sleep(2);
print "aliv"
proc2.communicate('S
')
print "alive"
time.sleep(6)
print "alive"
print proc2.communicate('L
')
time.sleep(6)
the program now goes well with the first input 'S
', but then stopped, and I the second 'L
' is kinda ignored.
Can anyone give me an idea why it's like this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…