Handling input confirmations in Linux shell scripting Handling input confirmations in Linux shell scripting linux linux

Handling input confirmations in Linux shell scripting


yes | ./script will answer y for everything.

Otherwise, write a script that prints the answers you want, eg:

 echo N echo Y echo Y


Usually you can call such interactive programs with an option to automatically answer yes to all questions. For instance, you can call apt-get with -y. From the man page :

-y, --yes, --assume-yes Automatic yes to prompts; assume "yes" as answer to all prompts and run non-interactively.


For Apt, the correct answer is to "preseed" your debconf database with the correct parameters. If Debconf finds the answer from its database, it won't ask. See also http://www.debian-administration.org/articles/394