This tutorial will show you how to make config changes with a simple tcl script and invoke the script from an IOS menu. I was recently presented with a scenario where the FXO ports on a customer router were not receiving the supervisory disconnect from the PBX.
 
Until I find a way to auto reset the ports with EEM and the long call duration flag, the temporary solution is to create a menu where the customer can view call durations and reset voice-ports with a menu. The tcl script performs a ‘shut’ and ‘no shut’ on the voice port.
 

 
 
menu
 
 

Create scripts and menus


 

  1. Store tcl scripts in flash to make changes to the config.
     
    Example:
    reset-000.tcl – resets voice-port 0/0/0
    reset-001.tcl – resets voice-port 0/0/1
     
  2. Create menu options that prompts the users to make changes.
     
    menu VOICE_RESET title @ Voice Menu @
    menu VOICE_RESET text 1 View active calls
    menu VOICE_RESET command 1 show call active voice brief
    menu VOICE_RESET options 1 pause
    menu VOICE_RESET text 2 Reset voice-port 0/0/0
    menu VOICE_RESET command 2 tclsh flash:reset-000.tcl
    menu VOICE_RESET options 2 pause
    menu VOICE_RESET text 3 Reset voice-port 0/0/1
    menu VOICE_RESET command 3 tclsh flash:reset-001.tcl
    menu VOICE_RESET options 3 pause
    menu VOICE_RESET text q Exit
    menu VOICE_RESET command q exit
    menu VOICE_RESET clear-screen
    menu VOICE_RESET line-mode
    menu VOICE_RESET single-space
     

 
Use the ‘menu VOICE_RESET’ command to initiate the menu or the username autocommand
 
username bill password 123455
username bill autocommand menu VOICE_RESET
 
 
Note: Click here for a Primary / Backup internet menu
 

Minimal Tcl command reference.


Basic Tcl commands that correlate directly to exec and config modes in IOS:

  • exec – Issue exec level commands
  • ios_config – Issue config level commands.

 
To test, enter ‘tclsh’ in exec mode on a router.

Router#tclsh
Router(tclsh)#exec “show version”
Router(tclsh)#ios_config “interface Fa0/0″ “no keepalive”

 
 
 

The Tcl script


 
This Tcl script will restart voice-port 0/0/0

tclsh

ios_config “voice-port 0/0/0″ “shut”

after 20

ios_config “voice-port 0/0/0″ “no shut”

 
 
 

Optional method of creating a tcl script.


Tcl scripts can be created within the Tcl shell…if you don’t want to use tftp.
 
1.Enter Tool Command Language shell

tclsh

 
 
2. Use tcl commands to create the ‘reset-000.tcl’ file in flash.

puts [open flash:reset-000.tcl w+] {

tclsh

ios_config “voice-port 0/0/0″ “shut”

after 20

ios_config “voice-port 0/0/0″ “no shut”

}

 

Be Sociable, Share!