06-25-2012 08:08 AM
Hi Guys, I have very little experience with TCL script, hoping yall can help me out. I have a customer who is wanting to send a copy of their running config to a tftp server every evening at around 10pm thats all they want to do. Any help on this would be greatly appreciated.
Thanks
Darren
06-25-2012 09:35 AM
Hi Darren,
The following CLI applet should perform what you want to do:
event manager applet backer
event timer cron cron-entry "0 10 * * *"
action 1 cli command "enable"
action 2 cli command "copy running tftp:" pattern "Address"
action 3 cli command "
action 4 cli command "
The related TCL script would be:
::cisco::eem::event_register_timer cron cron_entry "0 10 * * *"
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
if [catch {cli_open} result] {
error $result $errorInfo
} else {
array set cli1 $result
}
if [catch {cli_exec $cli1(fd) "enable"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_write $cli1(fd) "copy running tftp:"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_read_pattern $cli1(fd) "Address"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_write $cli1(fd) ""} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_read_pattern $cli1(fd) "Destination"} _cli_result] {
error $_cli_result $errorInfo
}
if [catch {cli_exec $cli1(fd) ""} _cli_result] {
error $_cli_result $errorInfo
}
# Close open cli before exit.
if [catch {cli_close $cli1(fd) $cli1(tty_id)} result] {
error $result $errorInfo
}
06-27-2012 06:24 AM
One minor note, to copy at 10 pm, the cron entry would be:
event timer cron cron-entry "0 22 * * *"
or
::cisco::eem::event_register_timer cron cron_entry "0 22 * * *"
11-15-2012 06:48 AM
It is so much easier to use 'archive' command
configuration/532
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