tj111 tj111 - 19 days ago 6
Linux Question

Have bash script answer interactive prompts

Is it possible to have a bash script automatically handle prompts that would normally be presented to the user with default actions? Currently I am using a bash script to call an in-house tool that will display prompts to the user (prompting for Y/N) to complete actions, however the script I'm writing needs to be completely "hands-off", so I need a way to send

Y|N
to the prompt to allow the program to continue execution. Is this possible?

Answer

This is not "auto-completion", this is automation. One common tool for these things is called Expect.

You might also get away with just piping input from yes.

Comments