Expect: The Firefighters
Friend
Cameron Laird
Most UNIX administrators are familiar with the Expect utility. They generally
know it as a way to automate password entry in FTP clients or password-management
system commands.
As crucial as its use can be in these applications, Expect has many other capabilities that may be less well known. Moreover, Expect is available for Windows. This article briefly surveys the range of Expect uses, then concentrates on ways Expect solves one-time emergencies. One major role that systems administrators play is to repair the damage missing files, lost passwords, and so on that arises in day-to-day information technology (IT) operation. These operations dont have to be as tedious as they seem. In many cases, Expect can turn hours of drudgery into a short scripting session.
Tcl/Tk Plus More
The first essential to understand about Expect is that its a full-blown,
general-purpose programming language. Yes, its a handy tool for automation
of password management, but thats only a showy side effect of its more
general capabilities.
Expect is an extension of the Tcl/Tk high-level language. That means it does everything Tcl/Tk does, and knows a few commands more, in the broad categories of:
- Debugging
- Character-oriented dialogue management
- Pseudoterminal management
Pseudoterminals take responsibility for funny character handling, as with password entry made invisible by manipulating terminal characteristics. Dialogue management has to do with pattern matching the conversation between a user and an application: the user types something, the program responds, the user types again, and so on. Expect defines a convenient language for making calculations based on such dialogues.
|