cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
263
Views
5
Helpful
5
Replies
Highlighted
Beginner

Writing an EEM that deletes itself before saving config

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
Beginner

Re: Writing an EEM that deletes itself before saving config

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
5 REPLIES 5
VIP Advisor

Re: Writing an EEM that deletes itself before saving config

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

Re: Writing an EEM that deletes itself before saving config

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#
Beginner

Re: Writing an EEM that deletes itself before saving config

You didn't save the config though

Beginner

Re: Writing an EEM that deletes itself before saving config

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
Beginner

Re: Writing an EEM that deletes itself before saving config

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

CreatePlease to create content
Content for Community-Ad
July's Community Spotlight Awards