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!

9 comments
christopherreynolds78
christopherreynolds78

First off, thank you for the write up. I always look forward to find something new to look at or think about. Now I am a bit AR about things, and this kind of stuck out at me: "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" It is said to place the command in Global Configuration Mode, but the command that is shown is placing it at the Privilege Exec mode. Global would have you here would it not? Router(config)# tclsh I have not double checked to see if it is a command at this level, but thought it might be something to check. Again ... I could be wrong =)

djdawson
djdawson

While I agree that TCL scripts can be used for some incredible things, I think this article would have been better it if had shown a more useful example. Pinging a static list of several addresses is hardly a feature I'd consider a "must have", and even if I did I could do it easier with a UNIX shell script or a Windows .bat script.

six325i
six325i

Or you can use "The Dude" for an entire network.

CDS
CDS

Can it be used to tftp the startup-config to the tftp server?

ktaisia
ktaisia

Is there a particular IOS version that TCL runs on or is it per router model? (ie. having to test every router that one has)

Photogenic Memory
Photogenic Memory

I've often scanned entire subnets with nmap on the job like this: nmap -sP X.X.X.X, X.X.X.X, X.X.X.X [ put in your own ip's here and seperate with a comma ] Although having the knowledge to accomplish your goals on different platforms is extremely useful. I just wish there were more examples on how to apply this scripting language in relation to the Cisco IOS. Interesting article but a massive teaser. The author should be punsihed for not providing enough examples, LOL! Just kidding!

Terry.Stevens
Terry.Stevens

It can be used to run a command as if you were on the target device. So, yes, you can use it copy the configuration to a TFTP server.

Terry.Stevens
Terry.Stevens

TCL 8.3 has been supported on many platforms since 12.2 in most IOS versions, beyond ip-base. The smaller access switches (e.g. 3750) need the enterprise image.

Editor's Picks