[c-nsp] Cisco - TCL script document

Rodney Dunn rodunn at cisco.com
Fri Sep 8 08:49:29 EDT 2006


And it gets much more powerful when you evaluate it in conjunction
with EEM.

It's amazing the corner case workaround and detection scnearios
I see it being used for nowadays.

ie: when a link comes up trigger a script to wait X seconds and check
    to see if it's a Cisco IP phone, if it is apply a specific QOS policy.

Rodney

On Fri, Sep 08, 2006 at 09:46:34AM +1000, Cisco Boy wrote:
> Hi Guys,
> Just want to share this document with you.
> 
> 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 
> <http://downloads.techrepublic.com.com/5138-10877-5827301.html> or with 
> Windows Scripting Host (WSH) 
> <http://techrepublic.com.com/5100-10879_11-5746352.html>.
> 
> 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 
> <http://en.wikipedia.org/wiki/Tcl>.
> 
> 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:
> 
> Router# *tclsh*
> 
> If the router does have TCL, the prompt will look like the following:
> 
> Router(tcl)#
> 
> 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 1.1.1.1 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 
> <http://tftpd32.jounin.net/>), 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 
> <http://www.cisco.com/en/US/products/sw/iosswrel/ps5207/products_feature_guide09186a00801a75a7.html>.
> 
> Cheers!
> CiscoBoy
> 
> 
> _______________________________________________
> cisco-nsp mailing list  cisco-nsp at puck.nether.net
> https://puck.nether.net/mailman/listinfo/cisco-nsp
> archive at http://puck.nether.net/pipermail/cisco-nsp/


More information about the cisco-nsp mailing list