Back to blog
Blog , How-To

Quick Bulk Changes with ciscocmd

John Marrett, Managed Network Service Technical Lead John Marrett, Managed Network Service Technical Lead October 24, 2019

In the past, we’ve written about the device inventory techniques. I’ve spoken about device configuration management. Here’s a video of my talk on the subject. Eric Lavoie, another member of our senior staff, spoke to me recently about needing to make a small change on 81 voice gateways. He was shocked by my casual estimate of the amount of time required to write the code to collect, validate, and correct the configuration. He went back to his desk, convinced there was an easier way to make the change, and he found one!

For quick one-off changes like this, you don’t need the heavy infrastructure required to validate and manage the configuration in an ongoing way. He found a program on Sourceforge, ciscocmd that allowed him to run commands on devices. Using this simple tool, he wrote a script to obtain the configuration of the devices and then parsing them in bash and generating a script dynamically to make changes to the configuration.

The script parses the output of sh dial-peer voice sum looking for busy lines with an IP starting with 10.10, it then generates a command to remove the peer.

Here’s the script entitled mybatch

#!/bin/sh

while read line; do
 echo "$line" | grep -q "voip.*busyout" && IF=$(echo $line | awk '{print  $1}')
 echo "conf t" > no_dialpeer.txt
 echo "no dial-peer voice $IF voip" >> no_dialpeer.txt
 echo "do wr mem" >> no_dialpeer.txt
 ./ciscocmd -Y -I -e -u admstack8 -p extremely-secure-password 
 -s extremely-secure-password -t $CISCOHOST -r ./no_dialpeer.txt -l log_batch_
done

And how it’s called from another instance of ciscocmd that calls the mybatch script using the -b parameter.

ciscocmd -Y -I -e -u admstack8 -p extremely-secure-password -s extremely-secure-password 
-T VG.txt -c "sh dial-peer voice summ | in 10.10.*busyout" -l log_remove_dialpeer 
-b ./mybatch --forcenext

If the ideas behind the script are appealing to you but extending and adapting it to your needs are more than you and your team can take on, then our Managed Services offerings may be the ideal supplement to help you.

Ready to take your unified communications from headache to hassle-free?

No throwing darts at proposals or contracts. No battling through the back-end. No nonsense, no run-around.