cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
583
Views
0
Helpful
2
Replies

Script to revert interface to default config and shut it down.

robert.paredes
Level 1
Level 1

Hi,

 

Hope someone could help me out here. I am currently tasked to manage all our devices, and by manage, means I have to shut all unused ports (down/down status) and revert it default configuration, . This is very tedious tasks since we have lots of devices and upon searching I came upon automating tasks via TCL and/or EEM scripting, this is my first time to encounter these and I have no background when it comes to TCL and/or EEM scripting for Cisco. I would appreciate if someone who had previously done this could provide me the scripts used to accomplished these tasks.

 

Thanks,

Robert

1 Accepted Solution

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

If you paste this into exec mode on the switch it should do what you requested.

 

#######

tclsh

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

2 Replies 2

Dan Frey
Cisco Employee
Cisco Employee

If you paste this into exec mode on the switch it should do what you requested.

 

#######

tclsh

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"
}

#########

Hi Daniel,

 

Thanks a lot! appreciate for taking your time in responding to my query. It worked by the way, one more question though, do you have any books that you can recommend for tcl scripting for newbies?

 

Thanks,

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco