Running Tclsh scripts on Cisco IOS

From CT3

Jump to: navigation, search

By Ivan Pepelnjak

Cisco IOS tclsh implementation behaves similarly to the tclsh implementations on other operating systems. The tclsh command without parameters starts the interactive shell. When one or more parameters are present in the tclsh command, the first parameter represents the name of the Tcl script to execute and the remaining parameters are passed to the script.

The first parameter of the Cisco IOS tclsh command is an Integrated File System (IFS) URL that can point to a local file (for example flash:myScript.tcl or nvram:script.tcl) or a file accessible through any of the remote file access methods available in Cisco IOS (TFTP, FTP, RCP, SCP, HTTP or HTTPS).


Store a simple helloWorld.tcl file on an external TFTP server with the IP address


puts "hello world" 

Executing the command tclsh tftp:// on a router that can reach the TFTP server will result in the "famous" hello world printout:

Router#tclsh tftp://
Loading helloWorld.tcl from (via FastEthernet0/0): !
[OK - 20 bytes]
hello, world
This document is part of the Tclsh on Cisco IOS tutorial.If you need professional help in planning, developing or deploying Tclsh scripts in your network, contact the author or NIL's Professional Services team
Personal tools


Main menu