id="info"

Networking

A tickle script you simply must have for your network engineering toolbox

Quickly perform a variety of duties on your Cisco router with the use of TCL (Tool Control Language), or "tickle" scripts. Lori Hyde provides you with one that you need to keep in your net admin toolbox.

TCL (Tool Control Language) scripting can be used on many of the Cisco router platforms to quickly perform a variety of duties. These scripts are affectionately referred to as "tickle" scripts. Since ping is one of the most common network connectivity tools, we'll set up a TCL script that can be run on your router to do the work for you. This sweet little script is one you'll want to be familiar with and keep handy in your toolbox.

First, you'll need to verify that your router and IOS support TCL. To do this, enter the tclsh command in the Global Configuration Mode.

Router# tclsh

The router prompt should return something like this:

Router(tcl) #

This means that TCL is supported on your IOS platform and you are now ready to enter your script commands.

I've found it's easiest to write your script with a text editor such as Notepad, and then copy this to the router. For this script, we'll use the foreach command to set up a routine that will loop through each IP address we supply.

Here is the format for this script:

foreach ip {
216.239.122.102
206.190.60.37
216.239.113.101
209.70.46.40
74.125.45.100
157.166.226.25
68.180.206.184
} { puts [exec "ping $ip"] }

We've set up "ip" as a variable, and then specified the IP addresses that become the data for this variable. We then finish with the actual exec level command that will be used with the variable.

Now we're ready to apply this script to the router. To begin, start by entering tclsh at the router prompt in enable mode.

Router#tclsh

The router prompt then indicates that we have entered into the tcl script mode as indicated by the added (tcl) at the prompt. Next, copy and paste the script from Notepad. Note that the router automatically adds the +> before each of the IP addresses. The router then runs the script and displays the results of each ping individually.

Router(tcl)#foreach ip {
+>216.239.122.102
+>206.190.60.37
+>216.239.113.101
+>209.70.46.40
+>74.125.45.100
+>157.166.226.25
+>68.180.206.184
+>} { puts [exec "ping $ip"] }
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 216.239.122.102, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 60/60/64 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 206.190.60.37, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/25/28 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 216.239.113.101, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 88/89/93 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 209.70.46.40, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/28/28 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 74.125.45.100, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/37/40 ms
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 157.166.226.25, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 68.180.206.184, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 80/81/84 ms
Router#

The script runs very fast, much faster than if I had done each ping separately, and it's easy to spot the failed pings. So create a script with your key network IP addresses and have it saved and ready for easy use when trouble arises. You'll be glad you have it!

Want to learn more about router and switch management? Automatically sign up for our free Cisco Technology newsletter, delivered each Friday!

Editor's Picks