cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3917
Views
5
Helpful
8
Replies

EEM $_cli_result end of line ?

apasquino
Level 1
Level 1

Hello,

I want to catch the description field of this output:

#sh run | sec l2vpn xconnect context 11111       
l2vpn xconnect context 11111
 description BLAH BLAH
 member GigabitEthernet0/7 service-instance 3501 
 member 50.50.0.34 11111 encapsulation mpls

so I wrote:

 action 210 cli command "sh run | sec l2vpn xconnect context $vcid"

 action 220 regexp "description "(.*)"" "$_cli_result" match desc

The regexp intercepts the whole output after the pattern "description ". I was not able to manage the \n \r etc special characters.

As a workaround  I configure like this:

l2vpn xconnect context 11111
 description "BLAH BLAH"
 member GigabitEthernet0/7 service-instance 3501 
 member 50.50.0.34 11111 encapsulation mpls

And parse like this:

 action 220 regexp "description "(.*)"" "$_cli_result" match desc  

Any clues to instruct regexp in order to catch the end of the line ?

Regards

 

Andrea

8 Replies 8

Joe Clarke
Cisco Employee
Cisco Employee

Try:

regexp "description (.*)[[:space:]]+member" $_cli_result match descr

Hello Joseph,

Sorry for the late answer. I've read many of your suggestion on this subject.

Anyway I get a null string back.

I have a new challenge: I wanted to revert to the previous config and the device refuses...

XXXXX(config-applet)#action 220 regexp "description "(.*)"" "$_cli_result" match desc
                                                        ^
% Invalid input detected at '^' marker.

Andrea

 

Well, 

 

at the least the new challenge is done. If I type:

action 220 regexp "description \"(.*)\"" "$_cli_result" match desc

it works, and the config shown is:

 action 220 regexp "description "(.*)"" "$_cli_result" match desc

Andrea

 

Hmmm, something didn't transfer right.  My action was:

 

regexp "description (.+)[ [ :space : ] ]+member" $_cli_result match descr

 

Apparently, CSC eats the double brackets.  I added spaces, but there should be no spaces between the brackets.

I have tried the regexp with the sequence of two open square brackets immediately followed by two closed square brackets and no space, but the result is (I believe) no match, bacause the variable desc remains stuck to the previusly deined value of "none".

On the other hand, interstingly, the result of:

action 170 regexp "description (.+)+member" $_cli_result match desc

gives a string (whatch carefully spaces and line feed):

"BLAH BLAH
 member GigabitEthernet0/7 service-instance 3501 
 "

So it stops after the SECOND line, and ignores the last one... Quite strange.

Andrea

 

Did you include the colons?  They are important.  Pretend '|' stands for '['.  It would look like:

 

||:space:]]

 

The word "space" and the colons are important.

The other way to do this is to iterate:

 

foreach line $_cli_result "\n"

regexp "description (.+)" $line match descr

if $_regexp_result eq 1

break

end

end

Joseph,

 

I reworked the config keeping in mind your hints and found (I believe)a good solution:

 action 170 regexp "description (££:print:€€+)" "$_cli_result" match desc

££ stand for double [

€€ stand for double ]

Andrea