Skip to main content

Managing Cisco Network Devices using Bash and Expect

Most of the time, managing lots of network devices are troublesome if you do not have a proper management software. In this post i will go through an example. The task that i want to achieve is getting existing tunnel configuration of cisco network devices, then creating a new tunnel configuration using them.

First install expect packages. In my case i use ubuntu:
# sudo apt-get install expect
Make a directory for logs:
# mkdir /tmp/expect_logs

There are some text files and bash, expect scripts:
1. devices_list : IP list of the cisco network devices.
2. cisco.sh : Main Bash script.
3. expect_get.exp : Expect script for getting existing device config.
4. expect_put.exp : Expect script for creating a new device config.

Contents of the scripts accordingly:
cisco.sh

expect_get.exp

expect_put.exp

Running cisco.sh in a while loop should do the trick.
# while read -r line; do ./cisco.sh $line; done < devices_list

Comments

Popular posts from this blog