Tech

Guides
 

A must have tickle script for your network engineering toolbox

By Lori Hyde, Special to ZDNet Asia
Thursday, July 30, 2009 09:03 PM

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!

Lori Hyde (CCNP, CCSP, and CCVP) has worked in a variety of IT jobs in her career, including user and network support, pre-sales engineering for a Cisco reseller, and security engineering for a large health insurance company. She is currently a network and security engineer for IT BusinessEdge. She also holds the GCIH and INFOSEC 4013 security certifications.



WORTHWHILE?

0

0 votes
Blog

Talkback 0 comments

There are currently no comments for this post.


Guest user

Guest user

Level: 
Joined: —
Already a member? Log in »



 

Loading...

Whitepapers/Case Studies

Downloads

Network Administration News



Tech Jobs Now!

Tags

  1. analysis
  2. bootexecute
  3. check box
  4. check disk
  5. data backup disaster recovery
  6. dialog box
  7. disk
  8. dos
  9. greg shultz
  10. microsoft windows
  11. microsoft windows vista
  12. registry
  13. registry editor
  14. start - up
  15. tool