03-02-2018 06:12 AM - edited 03-01-2019 06:26 PM
I have a doubt in using regexp in my eem script.
Can someone help me.
My Script:
event manager applet update-port-description
event neighbor-discovery interface regexp GigabitEthernet.* cdp add
action 1.0 cli command "enable"
action 2.0 cli command "config t"
action 3.0 cli command "interface $_nd_local_intf_name"
action 4.0 cli command "description $_nd_cdp_entry_name:$_nd_port_id [$_event_pub_time]"
Instead of applying this script to all the interfaces in my switch.
I would like to apply this only for interfaces between gi0/[1-5] and not to any other interfaces.
Can someone help me in modifying the below line in the script,
event neighbor-discovery interface regexp GigabitEthernet.* cdp add
Recommendations and suggestions are welcome !!!
03-02-2018 06:32 AM
Hi there,
Try this:
event neighbor-discovery interface regexp (GigabitEthernet0\/[1-5]\s) cdp add
cheers,
Seb.
03-02-2018 06:41 AM
This Didn't work.
Script didn't apply to any of the ports.
Regards,
Nishanth
03-02-2018 06:53 AM
hmmmm, maybe try it without the brackets:
event neighbor-discovery interface regexp GigabitEthernet0\/[1-5]\s cdp add
cheers,
Seb.
03-02-2018 06:55 AM
Yeah , I tried that without brackets.
Still the same.
03-02-2018 06:57 AM
maybe it doesn't like the escape character for the forward slash. try this one:
event neighbor-discovery interface regexp GigabitEthernet0.[1-5]\s cdp add
03-02-2018 07:04 AM
Still its a No.
interface regexp .*GigabitEthernet0/[0-9]+$ cdp add
This one worked, Still If I change the limit to gi0/[1-15] , It stopped working.
Check if you get some idea !
03-02-2018 07:20 AM
I didn't notice the .* you had at the beginning of the search. Does this work:
event neighbor-discovery interface regexp .*GigabitEthernet0.[1-5]\s cdp add
or
event neighbor-discovery interface regexp .*GigabitEthernet0/[1-5]\s cdp add
[0-15] won't work as it is not syntactically correct. Square brackets are for single character matches. If you wanted 0-15 you could use:
(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15)
or
([0-9]|[1][0-5])
03-02-2018 07:34 AM
event neighbor-discovery interface regexp .*GigabitEthernet0/[1-5]\s cdp add
event neighbor-discovery interface regexp .*GigabitEthernet0.[1-5]\s cdp add
Both didn't work,
Help me understand the below one and help me on extending that to gi0/[1-15]
interface regexp .*GigabitEthernet0/[0-9]+$ cdp add
03-02-2018 07:46 AM
bah this is some poor mans regex support in EEM! I guess \s is not supported either!
try:
.*GigabitEthernet0/([0-9]|[1][0-5])+$
If that doesn't work I don't know what will. You can check everything I've offered is valid here:
03-02-2018 03:17 PM
EEM regexp in the ED and in applets is limited to POSIX basic regexp support. So to match a space, use [[:space:]]. The Perl-compatible \FOO will not work.
03-02-2018 03:22 PM - edited 03-03-2018 11:29 AM
Hi Joe,
Do you have a link for the most authoritative Cisco doc on EEM equivalent regex voodoo??
cheers,
Seb.
03-02-2018 04:32 PM
In general, the syntax described at https://www.regular-expressions.info/posix.html will work within applets. Tcl supports Tcl-compliant REs.
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