I have a requirement to write an eem cli script that can be triggered using a pattern match and take parameters.
Basically the user has to do many repetitive tasks reconfiguring interfaces regularly. So instead of having to go into each interface individually and run the config that they can write a one word command and give it params which would be for example a comma separated list of interface names and then within my script i could parse the interface names and iterate over them performing the config operation on them.
so i'm just playing around with the cli policy.
::cisco::eem::event_register_cli occurs 1 pattern "nacdrop*" sync yes enter
# Import Namespaces
namespace import ::cisco::eem::*
namespace import ::cisco::lib::*
array set arr_einfo [event_reqinfo]
set full_command $arr_einfo(msg)
You can see here i want the command nacdrop to trigger this policy but when i try and run the command with arguments i get an error on the command line as its not a valid command and the policy doesnt trigger.
Ideal scenario run command
the script would then perform a set of config tasks on each of the 3 interfaces.
I thought the "enter" parameter to event_register_cli would do it as that is supposed to trigger the policy before the command is executed therefore before it determines it to be an invalid command. I do not have the latest version of eem however and suspect that the "enter" argument isn't being used as it isn't showing up as an option when i type ? to see what options are available although i don't get an error when registering the policy.
So my question is what version off eem was this "enter" argument introduced and will it allow me to run the policy and get around the invalid command problem.
Once i can run this policy and access the parameters to the cli command it opens up a lot for me in terms of automating repetitive tasks.
Hope someone can help.
Yes, the "enter" keyword allows you to react as soon as a matching command patter is typed on the prompt. EEM will get the command before it is sent to the parser. This will do what you seem to want to do.