Running Tcl procedures from command line

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:// command, you'll get the "famous" printout:
Router#tclsh tftp://
Loading helloWorld.tcl from (via FastEthernet0/0): !
[OK - 20 bytes]
hello, world

An revised version of this article is available in the CT3 wiki.

You can find more Tclsh-related information in the Tclsh on Cisco IOS tutorial. Sample Tclsh scripts are available in the Tclsh script library. If you need expert help in planning, developing or deploying Tclsh scripts in your network, contact the author.


  1. do you now how to pass a script as a argument?
    i need somethig like
    tclsh "wait 5000"

  2. Ivan Pepelnjak26 April, 2010 20:37

    Worst case: write a Tclsh script that executes its first argument.


You don't have to log in to post a comment, but please do provide your real name/URL. Anonymous comments might get deleted.