Cisco TCL Script Example

By | April 21, 2020

Cisco TCL Script Example

Sometime, We need to do some work repeatedly. For example, In many situation we need to ping multiple IPs and this is required on a interval repeatedly. manual ping is also good to check the connectivity. But it becomes boring and time consuming When we need to ping lot of IPs. This thing can done by using any Small tool. But what happen if IPs can’t ping without source and this source is configure on router. Ok, it is also fine. what will you do if identical configuration required on multiple ports. I know all these kind of thing can also be do using macro , automation tool , java script. But think if you are also not having this kind of tool and Linux server to run java script…… 🙂

Now we have a good news for you that Cisco has its own automation scripting language. This scripting technique is called TCL.

This is also useful when you are giving CCIE LAB exam and want to test your LAB using ping. Because if you will ping every IP manually then it will take lot of time.

Below is cisco TCL Script Example:

You can also add more IP addresses and no need to add +> sign. it will be add automatically when you will run the script. If you want to exit from TCL mode or quit/stop the script, then you can use tclquit command.

in below example, we are using 3 packets and size 1500 but you can adjust these as per your requirement.

Router#tclsh
Router(tcl)#foreach address {
+>1.1.1.1
+>2.2.2.2
+>3.3.3.3
+>4.4.4.4
+>5.5.5.5
+>6.6.6.6
+>7.7.7.7
+>8.8.8.8
+>192.168.1.1
+>192.168.2.1
+>192.168.3.1
+>} { ping $address repeat 3 size 1500 }

Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/8/12 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 4.4.4.4, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/8/12 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 6.6.6.6, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 7.7.7.7, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/8/12 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 1/1/1 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/8/12 ms
Type escape sequence to abort.
Sending 3, 1500-byte ICMP Echos to 192.168.3.1, timeout is 2 seconds:
!!!
Success rate is 100 percent (3/3), round-trip min/avg/max = 4/4/4 ms
Type escape sequence to abort.
R1(tcl)#tclquit

If you want to quit/stop the script then you can use the below command:

R1(tcl)#tclquit

If you want to check all the active IP addresses on your Cisco devices then you can run below command on all the Cisco devices.

R1#show ip alias
Address Type IP Address Port
Interface 192.168.1.1
Interface 192.168.2.1
Interface 192.168.3.1


We can also use below command to check the IP addresses of all active interfaces:

Router#show ip interface brief | exclude unassigned
Interface IP-Address OK? Method Status Protocol
FastEthernet0/1  192.168.1.1  YES manual up up
Serial0/0        192.168.2.1  YES manual up up
Loopback0        192.168.3.1  YES manual up up
Cisco TCL Script Example

you can see above Cisco TCL Script Example image.


Thanks For Reading …………………..

We will recommend you to read below posts:

One thought on “Cisco TCL Script Example

Leave a Reply

Your email address will not be published.