Automate input procedure to a binary file

If the program reads from standard input (as opposed to direct from the terminal), you could do something like

echo -e "answer1\nanswer2\nanswer3\n" | your_program

A here document may be more readable:

your_program <<'EOF'
answer1
answer2
answer3
EOF
do_more_stuff

(You can pick any string instead of EOF, just make sure to use the same in <<'somestring' and to mark the end of the input. The string must not appear as an input line. The end-of-input mark must not be indented.)

If you need more complex interaction then an expect script is what you want.


If you have many inputs, you can also put these inputs into a file

in.txt:
input1
input2
...
intputn

And call binary like this :

binary < in.txt