In my work I’ve not used “Expect” many times, but to do some jobs I’ve learnt how to use it, and I must say that to complete some tasks this program can help a lot and be a valid alternative to more complex solutions, like a complete program in python, php or your favorite scripting program.
But first a description of expect taken from his man page:
Expect is a program that “talks” to other interactive programs according to a script. Following the script, Expect knows what can be expected from a program and what the correct response should be. An interpreted language provides branching and high-level control structures to direct the dialogue. In addition, the user can take control and interact directly when desired, afterward returning control to the script.
In this article I’ll show you 2 examples on how to use it, to connect to a remote server via ssh and issue a command, to change the password of a user with the command passwd.