Skip to main content

Using Expect and TCL scripts to gather device configurations

From time to time I have to gather device configurations for storing them remotely or parsing using different scripts. Expect and TCL scripts are very handy as you can automate these configuration backups using just a short simple script. TCL and Expect are quite powerful, so you can do much more with these, this is just a little example on how useful these really are.

First you have to install TCL and Expect. Below you can see how to install these on CentOS 6.6 using Yum, which is really straightforward.

Below is the script used to fetch configuration from Juniper Junos device. The code below is commented for easy understanding. For Cisco just replace the needed configurations (“terminal length 0”, “show run” and such). You can of course configure some logic to check whether the device is Juniper or Cisco or whatever and run specific commands based on that.

That’s it! Now feel free to copy this as is and modify as you please. You can make the script runnable by making the script executable in the shell:



One thought to “Using Expect and TCL scripts to gather device configurations”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.