cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1402
Views
0
Helpful
9
Replies

execute commands on selected ports on switch

mhdganji110
Level 1
Level 1

Hi,

I need to select some ports of a switch with a specific condition and execute some commands of it.

For example, there are down ports (not connected) on a 48 ports switch with no specific order (2,3,7,34,45,47,..)

I'd like to select all of them, pipe this to another command (or maybe another way I donno) and then shut them all.

Is there anyway to do this simple task via IOS it or we need some TCL scripting or so?

 

Regards,

 

9 Replies 9

balaji.bandi
Hall of Fame
Hall of Fame

There are couple ways to do this. but before you doing this ? you need to make sure you are not shutting down the user Pc interface, example, switch have user Pc connected after work or laptop undock the port not connected. - originally user device is offline..this does not mean port is not connected.

 

once you are sure what you doing.

 

Options 1 : if it only 1 switch, i would take few minutes see what is not connected, put them in notepad ++ and paste them in config t  and shutdown teh interfaces.

 

Options 2 : if you looking to multiple switches, then it make sense to make it automate.

  for this one i always use Linux box with ssh access using expect command, get all the interface not connected, and shutdown them in scripting.

 

Hope this make sense ?  

 

 

BB

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

How to Ask The Cisco Community for Help

Thanks but I didn't find a specific answer in your post.

Could you please advise about the command you mentioned, Specific commands that we can run after SSH to device and find down ports and then shut them down?

 

Thanks

Hello,

 

I am thinking in the direction of an EEM/Tcl script that collects the status of your ports and then shuts them down based on that status. I assume you are referring to ports that are in down/down state ? How often do you want that to be checked ? A script could run each day, week, whatever you want...

Thanks but I didn't find a specific answer in your post.   <<- i have given you  direction how to do it, it has answer in it..i have bold the information for reference, if you not familiar with scripting then my solution may not work for you. 

 

Options 1 : if it only 1 switch, i would take few minutes see what is not connected, put them in notepad ++ and paste them in config t  and shutdown teh interfaces.

 

Options 2 : if you looking to multiple switches, then it make sense to make it automate.

  for this one i always use Linux box with ssh access using expect command, get all the interface not connected, and shutdown them in scripting.

 

 

BB

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

How to Ask The Cisco Community for Help

Dear balaji.bandi

yes that's what I want. But would you provide me with the script (using Expect) to do so?

 


@balaji.bandi wrote:

Thanks but I didn't find a specific answer in your post.   <<- i have given you  direction how to do it, it has answer in it..i have bold the information for reference, if you not familiar with scripting then my solution may not work for you. 

 

Options 1 : if it only 1 switch, i would take few minutes see what is not connected, put them in notepad ++ and paste them in config t  and shutdown teh interfaces.

 

Options 2 : if you looking to multiple switches, then it make sense to make it automate.

  for this one i always use Linux box with ssh access using expect command, get all the interface not connected, and shutdown them in scripting.

 

 


 

Hello
show ip int brief | in down
conf t

int range gig0/2 -3 , gig0/7 , gig0/35 , gig0/45 , gig0/47
shut
exit

 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Dear Paul

definitely I know how to filter output ..I want to be run as a routine and using scripts not on tens of switches and manually on different ports

Dear Paul

definitely I know how to filter output ..I want to be run as a routine and using scripts not on tens of switches and manually on different ports

Dear George
Yes, I'd like to have a script which will be run on about 100 switches per day or every other day. you can provide me with the script?
Review Cisco Networking products for a $25 gift card