The above link is via @Phaseit (Cameron Laird), to an oldish article of his on IBM developerWorks, but it is worth mentioning.
Expect is not new. It is an old Unix tool that lets you automate text-mode user interactions with various tools such as telnet, passwd, ftp, rlogin, etc. It lets you invoke such a tool and then interact with it programmatically via "expecting" prompts from the tool and then sending it responses, to make it do things. Hence the name Expect. It supports regular expressions.
I had used the tool a little, much earlier, and was blown away by its power. I also was lucky to get to read a book on Expect by its original creator, Don Libes, a scientist with the NIST, a standards institution of the USA.
One of the key things about Expect is that it uses Unix ptys to help perform its magic.
- Vasudev Ram