The language was created John Ousterhout at the University of California, Berkley. It's either installed by default or available through the package repositories in nearly every Linux distribution and flavor of BSD. ActiveState maintains an edition called ActiveTcl. The community edition has precompiled binaries for Windows, Mac and Linux. The Enterprise Edition adds binaries for HP-UX, Solaris and AIX. ActiveState also the home of ActivePerl and ActivePython, which are solid editions of Perl and Python for the same platforms.
Tclsh was added to Cisco IOS in version 12.3(2)T and 12.2(25)S, and to Cisco NX-OS in Release 5.1(1) to provide scripting capability. With it, you are able to run TCL commands directly from the Cisco IOS prompt, or to create and execute scripts written in the TCL language. Just about anything you can do in tclsh on a Linux or BSD system can be done in tclsh on a Cisco router. This of course assumes you're using straight TCL and not any add-on packages.
To use tclsh, simply type the command tclsh at the exec prompt. To exit tclsh, type tclquit. While within tclsh you can create scripts with the proc command, by typing proc script_name {, and then ending your script with a closing }. A great example of the power of this scripting environment can be found in this post at INE, where Brian McGahan, along with an assist from reader Jason Cook, demonstrates a TCL script to generate a number of random IP addresses and subnet masks tied to Loopback interfaces. I've used this script several times in the lab to quickly add routes into a routing protocol. If you're feeling really adventurous, you can even get your router to Tweet. And that's the beauty of scripting, you are able to quickly and easily automate the mundane tasks that aren't what you are working on and interested in, but still need accomplished.
And though it is not suggested, you can change your login shell on a Linux, BSD or Unix system to tclsh and do your day to day work in it as a means of learning the language and environment. However, as noted, its not suggested as it's not really suited as being used a login script wasn't in the design goals. See this article for more details.
I'll be getting more into TCL on IOS in the near future.
Some Good References to Get Started:
The official reference from Cisco:Cisco IOS Scripting with TCL Command
The Cisco book:
Tcl Scripting for Cisco IOS
Some books that come recommended by the TCL Developer Exchange:
Practical Programming in Tcl and Tk, 4th ed.
Tcl/Tk, Second Edition: A Developer's Guide
Tcl and the Tk Toolkit, 2nd ed.
Tcl/Tk 8.5 Programming Cookbook
Abdullah,
ReplyDeleteThe CCNA Security section of the Free CCNA Workbook is not complete yet. What you have found there is a lab that has not been published yet.