08-16-2016 04:29 AM
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
Solved! Go to Solution.
08-19-2016 05:53 AM
Thanks for your help.
Mike
01-19-2017 01:28 PM
How do you apply it to multiple ports?
Thanks
01-19-2017 05:48 PM
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
01-20-2017 07:19 AM
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
01-22-2017 11:32 AM
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.
03-02-2017 03:54 PM
2960-X and it doesn't have EEM support.
Starting with 15.2(4)E, 2960X/XR will support EEM.
Read THIS.
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