Tip: Using Autoexpect to Create Interactive Scripts in Linux
Scripting Interactive Tasks
I recently came across expect (the expect package in Debian and Ubuntu): a powerful utility that can script interactive operations.
" If you're not familiar with TCL syntax, you can get autoexpect from Wi-Fizzle.com. This spawns a shell, and then records everything you do in that shell. Hit Ctrl-C when you're done, and then either run the generated expect script as-is, or edit it to tidy it up a bit. In particular, autoexpect records keystrokes one by one, whereas you can put them all in at once. It records the full prompt, where the $ at the end may suffice.
Here's an example of a script generated with autoexpect then tidied-up. It logs into a server...
Read the rest of this Linux scripting tip at ServerWatch.com
Sponsored by BlackBerry
BlackBerry® Enterprise Server Express enables businesses of any size to quickly and easily get started with the BlackBerry solution. It provides advanced BlackBerry smartphone features with no additional software or user license fees, and works with any Internet-enabled BlackBerry data plan or a BlackBerry enterprise data plan. Download now!