In an EEM applet I want to use the output of a show command to decide if I need to make a change.
Here's the command whose output that I want to use:
BGP-DC2#sh run | i ^ neighbor 22.214.171.124 prefix-list
neighbor 126.96.36.199 prefix-list announce out
The prefix-list will either be announce or no-announce, if the prefix list is no-announce then I need to run a command to change it.
I feel that there must be an incredibly easy answer to this question but I can't find anything. I suspect that I somehow need to use the regex command or the action command pattern option.
Thanks in advance for your help.
I found this page  and it lead me to the following solution:
action 02.0 cli command "show run | i ^ neighbor 188.8.131.52 prefix-list"
action 02.5 set active_prefix_list "none"
action 03.0 regexp "prefix-list ([^ ]+)" $_cli_result result active_prefix_list
action 04.0 if $active_prefix_list eq no-announce
action 05.0 syslog msg "no-announce prefix-list in place, restoring announce prefix list"
action 06.0 cli command "conf t"
action 10.0 else
action 11.0 syslog msg "announce prefix-list in place, making no changes"
action 12.0 end
Yep, that should work. Though you may need to check your spacing. Hard to know here as HTML may be messing with stuff.