I'm trying out the EEM for the first time. I have written an applet that looks like this:
event manager applet SaveConfigToTFTP
event cli pattern "write" sync no skip no
action 1 cli command "enable"
action 2 cli command "configure terminal"
action 3 cli command "file prompt quiet"
action 4 cli command "end"
action 5 cli command "copy running-config tftp://tftp-server/router-confg"
action 6 cli command "configure terminal"
action 7 cli command "no file prompt quiet"
action 8 cli command "end"
It seems to work the first time I use it but not after that(the trigger is write). When I debug I can see that the script is running everytime i use write but when I check on the TFTP-server the file is not there. If i do a wr n manually i can see the file on the TFTP-server. Any idea what I'm doing wrong? Thanks.
The commands are always expanded before being passed to EEM. So, "write memory" will work just fine. To also match "copy running-config startup-config", you could try:
"(write memory|copy running-config startup-config)"
To set a timer, your applet could configure another, timer applet to run. For example:
action 010 cli command "event manager applet mytimer"
action 011 cli command "event timer countdown time 30"
action 012 cli command "action ..."