Evil_TTL> show | s

How to use TCL to Prepare Configuration Files

Category:Tools -> TCL

Ok, now that I know how to use TCL for creating configuration files I remember that day when our client bought 25 autonomous access points and they all had to be preconfigured for deployment. That day I didn’t know anything about scripting languages so I spent a couple of days preconfiguring each AP and double or even triple checking the configurations made. So don’t repeat my mistake now and use a TCL script to help you create configurations. You can easily adapt the script to your liking.

Say you need to preconfigure a hostname, an ip address and a mask. Start by preparing configuration text with some variables:

hostname $hostname
!
interface 
BVI1
ip address $ipaddress $ipmask 

Now we have to fill in the variables:

foreach {hostname ipaddress ipmask} {
AP01
-ACC-LOC01    172.16.1.1    255.255.255.0 
AP02
-ACC-LOC01    172.16.1.2    255.255.255.0
AP03
-ACC-LOC01    172.16.1.3    255.255.255.0
AP04
-ACC-LOC01    172.16.1.4    255.255.255.0
AP05
-ACC-LOC01    172.16.1.5    255.255.255.0

When you are done, make a *.txt or *.tcl file and save the script with additions as follows:

foreach {hostname ipaddress ipmask} {
AP01
-ACC-LOC01    172.16.1.1    255.255.255.0 
AP02
-ACC-LOC01    172.16.1.2    255.255.255.0
AP03
-ACC-LOC01    172.16.1.3    255.255.255.0
AP04
-ACC-LOC01    172.16.1.4    255.255.255.0
AP05
-ACC-LOC01    172.16.1.5    255.255.255.0

} {set data 
"

hostname $hostname
!
interface BVI1
ip address $ipaddress $ipmask

"
      
set filename "${hostname}.txt"
      
set fileId [open $filename "w"]
      puts 
-nonewline $fileId $data
      close $fileId

This is going to be a TCL script file. To run it you need a TCL kit. Download it first: File:tclkit win32.upx.zip. Unpack it and place it into a folder with the script file you’ve created.

Start tclkit-win32. From File - Source menu open the script file and in a moment 5 configuration files would appear in the same folder.

By privilege15