cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1103
Views
0
Helpful
5
Replies

EEM/TCL Script to shut down interfaces when in "notconnect" state

fountouk89
Level 1
Level 1

Is there a TCL Script to apply the "shutdown" command ONLY if the interfaces of the switch are  in "notconnect" state ?
"notconnect" info will be retrieved by issuing the "show interfaces" command

1 Accepted Solution

Accepted Solutions

Hello,

@Dan Frey has posted a great, simple TCL script that should work. I hope he is fine with me reposting this...

Get into TCL:

Switch#tclsh

run the script below, and press <ENTER>. The line 'ios_config "default interface $port"' is optional, as this resets the interface(s) to the default.

set lines [exec sh int | inc notconnect]
set lines [split $lines "\n"]

foreach line $lines {
regexp {([a-zA-Z0-9\/]+) is down, line protocol is down \(notconnect\)} $line match port
ios_config "default interface $port"
ios_config "interface $port" "shutdown"
puts "Interface $port set to default"
}

View solution in original post

5 Replies 5

but if it not connect it shutdown automatic ? what is this interface ? is it dialer ?

If it is "notconnect" --> shutdown the port automatically with the script

Otherwise do nothing

I am mainly concerned with ethernet ports (fast-eth, gig-eth, ten-gig, etc..)

Hello,

@Dan Frey has posted a great, simple TCL script that should work. I hope he is fine with me reposting this...

Get into TCL:

Switch#tclsh

run the script below, and press <ENTER>. The line 'ios_config "default interface $port"' is optional, as this resets the interface(s) to the default.

set lines [exec sh int | inc notconnect]
set lines [split $lines "\n"]

foreach line $lines {
regexp {([a-zA-Z0-9\/]+) is down, line protocol is down \(notconnect\)} $line match port
ios_config "default interface $port"
ios_config "interface $port" "shutdown"
puts "Interface $port set to default"
}

balaji.bandi
Hall of Fame
Hall of Fame

some time TCL script has limitation depends on what device, suggest to use EEM Script for this task.

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help