11-05-2010 06:02 AM
I have the following simple Tcl script which can be executed from CLI using command "tclsh filename.tcl":
# --- start of script ---
typeahead "\n\n"
exec copy nvram://startup-config ftp://username:password@10.1.1.1/backup-confg
# --- end of script ---
Now I would like to turn it into EEM policy which will copy startup-config to FTP server each time user types in command "copy running-config startup-config". I created directory flash://tcl/, copied my script there and entered these commands:
event manager directory user policy flash://tcl/
event manager applet archive
event cli occurs 1 sync no pattern "copy running-config startup-config"
How should I complete my configuration and how should I change my script?
Thanks in advance!
11-05-2010 09:56 AM
You don't need your Tcl script anymore, nor do you need the event manager directory user policy command. This applet should do what you want:
event manager applet archive
event cli pattern "copy running-config startup-config" sync no
action 1.0 cli command "enable"
action 2.0 cli command "copy start ftp://username:password@10.1.1.1/backup-config" pattern "Address"
action 3.0 cli command "10.1.1.1" pattern "Destination"
action 4.0 cli command "backup-config"
11-05-2010 01:17 PM
Thank you very much.
I'll try this solution as soon as it's possible.
11-08-2010 11:05 AM
Thank you once again, Joseph.
Your appllet has solved my problem, although I had to customise it a little to make it work on my router Cisco 2851 (IOS Version 12.4(18)):
event manager applet archive
event cli pattern "copy running-config startup-config" sync no skip no occurs 1
action 1.0 syslog priority notification msg "Trying to upload running-config to FTP server..."
action 2.0 cli command "enable"
action 3.0 cli command "configure terminal"
action 3.2 cli command "file prompt quiet"
action 3.4 cli command "end"
action 4.0 cli command "copy startup-config ftp://user:password@10.1.1.1/backup-config"
action 5.0 cli command "configure terminal"
action 5.2 cli command "no file prompt quiet"
action 5.4 cli command "end"
11-08-2010 01:00 PM
You have EEM 2.1. The ability to do interactive commands in applets was added in EEM 2.3. You would either need to use an EEM Tcl policy, or do what you've done and configure "file prompt quiet".
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