06-11-2018 02:44 AM - edited 03-01-2019 06:38 PM
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.
Solved! Go to Solution.
06-11-2018 08:52 AM
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.
06-11-2018 08:52 AM
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.
06-12-2018 02:04 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide