cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1911
Views
5
Helpful
5
Replies

Writing an EEM that deletes itself before saving config

pingduck
Level 1
Level 1

This seems like a chicken and egg problem. Is there a way to write an EEM script that executes only once? Ideally, does not present in startup-config at all?

1 Accepted Solution

Accepted Solutions

Would it be better...?

event manager applet test1
event none
action 005 cli command "enable"
action 010 cli command "show users"
action 011 puts "$_cli_result"
action 015 cli command "conf t"
action 020 cli command "no event manager applet test1"
action 025 cli command "do wr mem"
action 030 puts "saved"
!


IOU6#event manager run test1

Line User Host(s) Idle Location
0 con 0 idle 00:00:00
* 2 vty 0 idle 00:00:00 EEM:test1

Interface User Mode Idle Peer Address

IOU6#

IOU6#saved

IOU6#
IOU6#show archive config diff
!Contextual Config Diffs:
line con 0
-length 0

View solution in original post

5 Replies 5

balaji.bandi
Hall of Fame
Hall of Fame

Remove from current config not possible, i have not tried, but this should work.

 

write 2 EEM Scripts, once for the one time task EEM,.

another one to remove first EEM script, since seconds one do not do anything just removing the EEM Script. so no more valid in the config.

make sense ?

 

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

ngkin2010
Level 7
Level 7
IOU6(config)#do show run | b test1
event manager applet test1
event none
action 005 cli command "enable"
action 010 cli command "show users"
action 011 puts "$_cli_result"
action 015 cli command "conf t"
action 020 cli command "no event manager applet test1"
!

IOU6#event manager run test1

(..omitted..)

IOU6#show run | b test1
IOU6#

You didn't save the config though

Would it be better...?

event manager applet test1
event none
action 005 cli command "enable"
action 010 cli command "show users"
action 011 puts "$_cli_result"
action 015 cli command "conf t"
action 020 cli command "no event manager applet test1"
action 025 cli command "do wr mem"
action 030 puts "saved"
!


IOU6#event manager run test1

Line User Host(s) Idle Location
0 con 0 idle 00:00:00
* 2 vty 0 idle 00:00:00 EEM:test1

Interface User Mode Idle Peer Address

IOU6#

IOU6#saved

IOU6#
IOU6#show archive config diff
!Contextual Config Diffs:
line con 0
-length 0

Awesome! I thought I tried something similar but it didn't work for me. But I tried your example and it indeed works.