I am to automate the installation phase of a legacy system, because I do not want to put more efforts again and again when ever I want to install it. During the installation process on Linux Terminal, I have to answer some questions regarding the basic configurations. Indeed, it is easy to automate the shell commands by putting them all in a batch file like the following:
bin/startServer destination/sub_v1
bin/startAdminInterface
....
However, I do not know how to automate the answers of a specific questions like the following:
Enter the server's IP address:
Enter the email of the contact person:
Would you like to disable UDP services?(y/n) [n]:
....
Is there any tool or programming language can deal with this situation? or Is there any way to pass the answers as a parameters within the batch file?
Thanks in advance.
The classic Linux tool for this job is expect.
With
expect
one can expect different questions and variations on a question, and the question does not have to be typed exactly.expect
does not blindly answer every prompt, but rather it provides answers to the questions actually asked.Here is a short example: