Cisco TCL Ping Script

As I have been working on my CCIE lab studies, I have been using ping (like everyone else) as a way to verify connectivity between the hypothetical “sites” on a large topology for instance. Nothing special, just making sure routing is working. If there are multiple sites or devices you need to verify, you know the time it takes to find the needed IP addresses, change the ping command, and test each device. One common solution that is useful and saves a bit of time is to use a TCL ping script. This way you can have multiple IP addresses specified from the start and let the script go through each of them automatically. The script would look a bit like this:

 

foreach address {
1.1.1.1
2.2.2.2
3.3.3.3} { ping $address
}

That is the script in a very basic form. You can add IP addresses the list as needed. The process of running it on an IOS device and getting your needed output would look a bit like this:

R1#tclsh
R1(tcl)#foreach address {
+>(tcl)#1.1.1.1
+>(tcl)#2.2.2.2
+>(tcl)#3.3.3.3} { ping $address
+>(tcl)#}
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/3/4 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/5 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/5 ms
R1(tcl)#tclquit
R1#

Another point to keep in mind. Look at the beginning and end of that output. “tclsh” is used to enter the TCL scripting mode and then you must enter “tclquit” at the end when you wish to exit the scripting mode. Obviously there is a lot more that you can do with TCL, but making a TCL ping script is a very common use. For more uses and documentation, click this link to check out the Cisco documentation: Cisco IOS Scripting with Tcl

Facebooktwittergoogle_plusredditpinterestlinkedintumblrmail
Kevin Blackburn

Kevin Blackburn

Cisco CCNP, Senior Network Engineer in the Healthcare Industry. Currently working on my CCIE R&S which is the focus of most of my latest blog posts. #NFD15 Delegate.

Leave a Reply

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