08-08-2022 05:34 AM
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
Solved! Go to Solution.
08-09-2022 12:32 AM
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"
}
08-08-2022 05:46 AM
but if it not connect it shutdown automatic ? what is this interface ? is it dialer ?
08-08-2022 07:02 AM
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..)
08-08-2022 08:41 AM
08-09-2022 12:32 AM
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"
}
08-08-2022 07:26 AM
some time TCL script has limitation depends on what device, suggest to use EEM Script for this task.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide