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.