Running Tcl Procedures from Cisco IOS CLI

Starting in IOS release 12.3(2)T, Tcl shell is accessible from the command line interface with the tclsh command. After entering this command, you get the Router(tcl)# prompt and can enter individual Tcl commands (the help is confusing, though – you get help on exec-mode commands, but none of them work).

What the documentation fails to tell you, though, is that you can specify a file name (actually an IFS URL) as the parameter to the tclsh command to execute the Tcl commands in that file. The file can be local (stored in flash or even NVRAM) or remote, in which case the router downloads the file and executes it. For example, if you store a simple helloWorld.tcl file …

puts "hello world";

… on an external TFTP server and execute it with the tclsh tftp://10.0.0.10/helloWorld.tcl command, you’ll get the “famous” printout:

Router#tclsh tftp://10.0.0.10/helloWorld.tcl
Loading helloWorld.tcl from 10.0.0.10 (via FastEthernet0/0): !
[OK - 20 bytes]
hello, world

2 comments:

  1. do you now how to pass a script as a argument?
    i need somethig like
    tclsh "wait 5000"
  2. Worst case: write a Tclsh script that executes its first argument.
Add comment
Sidebar