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

EEM Nested Conditional

ling20125
Level 1
Level 1

Hi all,

  I have an EEM script written using CLI that includes a nested conditional. I have no problem running only one of the conditional. However, if I nest one conditional within the other, it just gives me this "Missing "end" action in conditional block" message. Here is the basic core structure of my script:

foreach RUN A LOOP

  if CONDITION

     BLAH BLAH BLAH

     exit

     break //if the condition in the if block returns true, I want to do something and break out of the entire foreach loop. Do I use them (exit and break) both or just one?

  else

     BLAH BLAH BLAH

     exit

     continue //again, do I need them both or just 'continue'?

  exit //exit foreach loop

  if CONDITION //another IF conditional

     BLAH BLAH BLAH

     exit

end

  If nested conditional is allowed, is my script in the correct syntax?

Regards,

Angela

1 Reply 1

Joe Clarke
Cisco Employee
Cisco Employee

Nested conditionals are supported.  It's hard to see if there is a problem with your code or a problem with the device as you did not post your actual applet or IOS version.  However, from the pseudo-code above, it does appear you're missing an "end".  Here is a working applet I wrote to illustrate the nested conditional:

event manager applet nct

event none

action 001 set var "5"

action 002 if $var lt 10

action 003  if $var gt 1

action 004   if $var eq 5

action 005    puts "Found it!"

action 006   end

action 007  end

action 008 end

Note how each conditional must be terminated with an associated "end" action.

Review Cisco Networking for a $25 gift card