Skip to Main Content
Cisco IOS Cookbook, 2nd Edition
book

Cisco IOS Cookbook, 2nd Edition

by Kevin Dooley, Ian Brown
December 2006
Intermediate to advanced content levelIntermediate to advanced
1188 pages
72h 8m
English
O'Reilly Media, Inc.
Content preview from Cisco IOS Cookbook, 2nd Edition

Expect

Expect is another scripting language that helps solve a different type of problem. Where Perl’s strength is in pattern matching, Expect provides a way to automate interactive applications. We usually use Expect to imitate user sessions on a router to automate command-line-based tasks.

The Expect program is able to send one or more lines of output, such as router commands, and capture the results. And it can also react to whatever the router sends it in return. This could be as simple as sending a user ID and waiting for the password prompt, or you could use this feature to check for various error conditions and react appropriately.

We often write scripts in Expect to automate boring repetitive tasks. Computers are good at these tasks, people aren’t. People make typos and get bored or blink and miss key pieces of information. Also, because Expect can react immediately to the router’s responses, the script can generally execute a series of commands very quickly. We think it’s better to spend your time doing something productive while the computer is logging into all of your routers to do show commands. Expect lets us do this.

Expect is free to download, distribute, and use for any purpose. There are both Unix and Windows versions, and there are even companies doing commercial support for Expect. We wrote and tested all of the scripts in this book using Expect Version 5.31.2 on a Unix platform.

You can download Expect from the official web page at http://expect.nist.gov/. This site ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning the Cisco Application-Centric Infrastructure (ACI)

Learning the Cisco Application-Centric Infrastructure (ACI)

Rene Cardona

Publisher Resources

ISBN: 0596527225Supplemental ContentErrata Page