How to make shell script interact with program

Hello all!

I have a C program that runs on a loop, prompting the user for input until it is exited. I want to create a shell script that can run this program and provide input. How can I do this? I have investigated 'expect' and piping to stdin, but haven't had any success. Any help is welcome!

Thank you :slight_smile:

http://www.unix.com/shell-programming-scripting/122855-reading-keyboard-shell-script.html\#post302367979

What did you try and what does "haven't had any success" mean? What did happen? What did you want to happen?

The usual method, assuming that the C program reads from the standard input is:

printf "%s\n" y n filename whatever | name_of_C_program