Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

Tcl script to copy config to tftp server every evening

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

3 REPLIES
New Member

Tcl script to copy config to tftp server every evening

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 "" pattern "Destination"

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
}
Cisco Employee

Tcl script to copy config to tftp server every evening

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

New Member

Tcl script to copy config to tftp server every evening

4908
Views
0
Helpful
3
Replies
CreatePlease login to create content