Automating mundane tasks with Expect

Expect is a UNIX program based on the Tcl programming language. It allows for quick and easy automation of interaction with other programs. For example, Expect can be used to write a script which launches FTP, enters a password when prompted, navigates to a directory, downloads a file, and finally quits.

My current development work requires me to login to a remote server quite frequently, launch a session of SAS, and execute a program to connect to an Oracle database. Prior to Expect, it took me 30 to 45 seconds to login. Now that I have the login and SAS startup processes automated via Expect, it takes mere seconds to do the same thing.

Expect isn’t for everyone, but if you need to automate an interactive UNIX program it can be a lifesaver. Visit the Expect web site for more information, including a number of useful example scripts.