Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
New Member

TCL Script to shutdown unauthorized IP phones

Hi... I’ve tried to modify this script to shutdown unauthorized IP phones like this:

set interfacesWithVOiPNeighbors [regexp -all -line -inline "^\[A-Za-z0-9\]+\[ \]+(\[A-Za-z\]+\[ \]+\[0-9\/\]+)" [exec "show cdp neighbors | include IP Phone"]]

puts interfacesWithVOiPNeighbors

puts $interfacesWithVOiPNeighbors

set interfaces [regexp -all -line -inline "^\[A-Za-z\]+(\[0-9\/\]+)" [exec "show authentication sessions | include Authz Success"]]

puts interfaces

puts $interfaces

set index 0

while {$index < [llength $interfaces]} {

set interface "[lindex $interfaces [expr $index]]"

set indexOf [lsearch $interfacesWithVOiPNeighbors $interfaces]

if {$indexOf < 0} {

puts "Shutting down $interface"

puts $interface

ios_config "int $interface" "shutdown" "no shutdown" "exit"

}

set index [expr $index + 3]

}

the output is:

interfacesWithVOiPNeighbors
{SEP0021A02D2436  Fas 0/7} {Fas 0/7} {SEP0021A02D3497  Fas 0/3} {Fas 0/3}
interfaces
Fa0/7 0/7 Fa0/3 0/3
Shutting down Fa0/7
Fa0/7
Shutting down 0/3
0/3

What am I missing?

Thanks and regards

This script is based on https://learningnetwork.cisco.com/thread/63551 and i’m using Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 12.2(55)SE3, RELEASE SOFTWARE (fc1).

74
Views
0
Helpful
0
Replies
CreatePlease to create content