cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
15341
Views
35
Helpful
20
Replies

TcL Script to shut down port on a time schedule

burleyman
Level 8
Level 8

Is there a way to have a TcL script shut and no shut ports on a schedule? for example; shut down the ports at 7:00am and no shut the port at 3:30pm?

Thanks,

Mike

20 Replies 20

Thanks for your help.

Mike

alimpervizi
Level 1
Level 1

How do you apply it to multiple ports?

Thanks

You can create a list of ports and iterate through it.  For example, using the applet example here, you can do something like:

set ports "Gi0/1 Gi0/2 Gi0/3"

foreach port $ports

 cli command "int $port"

 cli command "shut"

end

Joe,

Is the example that you provided for a switch that has EEM support?

I have 2960-S and 2960-X and it doesn't have EEM support.

I am trying to make the following to work, but is is not working. What need to be changed?

Thanks

tclsh
puts [open "flash:shutdown_ports.tcl" w] {set ports [lindex $argv 0]
ios_config "int range $ports" "shut" "end"
}
tclquit
config t
kron policy-list policy_ShutdownPorts
cli tclsh flash:shutdown_ports.tcl "Gi1/0/1 - 18"
exit
kron occurrence policy_ShutdownPorts at 23:30 recurring
policy-list policy_ShutdownPorts

____________________________________________________________________

tclsh
puts [open "flash:No_shutdown_ports.tcl" w] {set ports [lindex $argv 0]
ios_config "int range $ports" "no shut" "end"
}
no
tclquit
config t
kron policy-list policy_NOShutdownPorts
cli tclsh flash:No_shutdown_ports.tcl "Gi1/0/1 - 18"
exit
kron occurrence policy_NOShutdownPorts at 23:31 recurring
policy-list policy_NOShutdownPorts

The code looks fine to me, but tclsh doesn't work well with AAA.  If you have AAA command authz on this switch, it may not work as the user running the script isn't authorized to run the commands.

That said, since you really didn't provide any details as to what "doesn't work" means, it could be that the switch's clock is not what you think it is, or there is some other issue preventing the ports from being manipulated as a range.

2960-X and it doesn't have EEM support.

Starting with 15.2(4)E, 2960X/XR will support EEM. 

Read THIS.