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

Delay an action in eem

maty
Level 1
Level 1

Hello,

I have to make a script that must wait for a few moments before continuing the actions.

The problem is that when I use two nested scripts the action regexp command does not work (it does not recognize the match variable).

I have to do some actions at the beginning after waiting a few minutes before checking the state of an interface and continue depending on this state. To check this state I do a "show interface X" and I get the character "up" or "down".

In just one script I can get it but in the two nested it doesn't run (match variable is not known)

event manager applet test
 event none
 action a01.0 cli command "enable"
 action a01.1 cli command "conf t"
 action a03.0 cli command "do sh int ATM0"
 action a05.0 regexp "ATM0 is ([a-z]+)" "$_cli_result" match state
 action a07.0 puts "the state of int EFM is $state"

 Router# event manager run test
 the state of int EFM is down

 
 event manager applet MyEvent
 event none
 action a01.0 cli command "enable"
 action a01.1 cli command "conf t"
 action a03.0 syslog msg "hello"
 action b29.0 cli command "event manager applet recupStateInt"
 action b30.0 cli command "event timer countdown time 120"
 action b31.0 cli command "action a01.0 cli command $q enable $q"
 action b32.0 cli command "action a01.1 cli command $q conf t $q"
 action b33.0 cli command "action a03.0 cli command $q do sh interface ATM0 $q"
 action b34.0 cli command "action a04.0 regexp  $command1 match state"
 action b35.0 cli command "action a05.0 puts $q the state is $state $q"

 

Router# event manager run MyEvent
 *Jun 11 08:32:50.821: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: state
 *Jun 11 08:32:50.821: %HA_EM-3-FMPD_ERROR: Error executing applet ATM-EFM statement b35.0
 *Jun 11 08:32:50.821: %HA_EM-6-LOG: ATM-EFM : DEBUG(cli_lib) : : CTL : cli_close called.

 

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

In this case add:

event manager environment s $state

Then do:

action b35.0 cli command "action a05.0 puts $q the state is $s $q"

 

This way, you delay the resolution of the variable state once it's in the nested applet.

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

In this case add:

event manager environment s $state

Then do:

action b35.0 cli command "action a05.0 puts $q the state is $s $q"

 

This way, you delay the resolution of the variable state once it's in the nested applet.

Thank you Joe, I get it now

Review Cisco Networking for a $25 gift card