I am trying to run a Windows (XP) command line program which prompts for 'Enter' or 'y' to continue. Currently, I can respond to the 'y's by running the program as:
echo y | name_of_binary
in a batch file.
I can't figure out how to tell the shell to respond with 'Enter' or 'y' when this is required. If it gets to a 'Press Enter to continue' sort of prompt (of which there are not very many, but enough to cause problems) and echoes 'y', it get stuck in a weird loop and won't accept any input (it spews thousands of 'press enter to continue's). If I could echo first an Enter and then a 'y' in sequence, that might work, but none of the methods I tried for echoing an 'Enter' keypress worked.
I am ultimately calling this batch file through os.system()
in Python. If there is a way to get Python to run the binary (through os.system(name_of_binary)?) AND respond to the prompts, that would be ideal. I have already tried os.system(echo y | name_of_binary
) which behaved the same way as the batch file (as it should). Should I be using a different approach, or can I solve this by modifying the 'echo ...' command I'm currently using?