At some point in your career as an administrator, it's a good bet that you've used a script to automate some common task. Maybe you've written scripts in your Linux bash shell or with Windows Scripting Host (WSH).
However, up until recently, there wasn't a scripting language for Cisco routers; there were some available tools, but no open scripting language. Cisco changed this with Cisco IOS 12.3(2)T by adding the Tool Command Language (TCL) to the Cisco IOS. Let's take a closer look.
Pronounced as "tickle," TCL is a powerful but easy way to learn dynamic scripting language. It's an open programming language developed by John Ousterhout.
While the scope of this article prevents us from exploring TCL in detail, let's take a look at the basics of using TCL as well as some examples. You can find more information on TCL programming and its syntax by checking out its Wikipedia entry.
Before trying to use TCL on your router, make sure that you're using release 12.3(2)T, 12.2(25)S, or greater. To determine whether your router includes TCL, enter the tclsh command in Global Configuration Mode. Here's an example:
If the router does have TCL, the prompt will look like the following:
If the router doesn't include TCL, it will think you're trying to Telnet to a host called tclsh, and it will try to perform a DNS lookup on that host.
Once you're at the IOS TCL prompt, enter the tclq command to exit, as shown below:
Router(tcl)# tclq Router#
Now, let's look at some examples of using TCL. To run a User EXEC Mode command on a Cisco router, you would begin each command with exec and place the actual command in quotes. Here's an example:
Router(tcl)# exec "show version"
To use a Global Configuration Mode command, begin the command with ios_config. Then, put the Global Configuration Mode command in quotes, following with the sub-command in quotes. Don't forget that you must put the command and sub-commands on the same TCL command line, or they won't work. Here's an example:
Router(tcl)# ios_config "interface serial0/0" "ip address 18.104.22.168 255.0.0.0"
These are two simple examples of using TCL with a single command. But once you've learned the TCL scripting language, you can write much more complex scripts.
For example, you could write a script to ping a list of IP addresses, or you could write one to filter output from commands and format it to your liking. You could even write a script to send an e-mail message from a router.
Once you understand the basics of TCL in the IOS, you'll quickly find that it's easier to edit TCL scripts on the desktop and transfer them to the router with a TFTP server (such as tftpd32.exe), rather than manually entering scripts at the router.
TCL on Cisco IOS routers is a relatively new feature, but this feature will likely grow in popularity over time as admins become more familiar with it. For more information, check out the Cisco IOS Scripting with Tcl documentation.
Miss a column?
Check out the Cisco Routers and Switches Archive, and catch up on David Davis' most recent columns.
Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!
David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.