EEM IP address extract

Answered Question
May 14th, 2012

Hello.

I am new to the Cisco world

There's a task where I need to extract the ip address of an interface from the cli output.

I am trying to accomplish this via EEM.

The script is working when I input the "sh ip int brief command"

However when I replace this command by "ping routerA.com"

and run the applet, there's no output.

The script is displayed below:

event manager applet showIP

event none sync yes

action 1.0 cli command "enable"

action 1.5 cli command "ping routerA.com "

action 2.0 regexp " [0-9.]+ " $_cli_result result

action 3.0 puts "$result"

Can someone help me ?

I have this problem too.
0 votes
Correct Answer by Joseph Clarke about 1 year 11 months ago

I don't know what the output looks like off the top of my head, but I do know you're missing the enable command.  Add:

action 0.5 cli command "enable"

Correct Answer by Joseph Clarke about 1 year 11 months ago

Try this:

event manager applet getIP

event none sync yes

action 1.0 cli command "enable"

action 1.5 cli command "ping 10.1.1.1"

action 2.0 regexp "to ([0-9\.]+)" $_cli_result match ip

action 3.0 puts "$ip"

  • 1
  • 2
  • 3
  • 4
  • 5
Average Rating: 5 (2 ratings)
Correct Answer
Joseph Clarke Mon, 05/14/2012 - 09:58

Try this:

event manager applet getIP

event none sync yes

action 1.0 cli command "enable"

action 1.5 cli command "ping 10.1.1.1"

action 2.0 regexp "to ([0-9\.]+)" $_cli_result match ip

action 3.0 puts "$ip"

cedric.philogene Mon, 05/14/2012 - 22:45

Hi Clarke.

Thanks for the extremely prompt and accurate information.

I tested your solution and it works.\

Cheers

~Cedric~

cedric.philogene Thu, 05/17/2012 - 06:03

Hello,

I need to extract an IP address from the "crypto map" command but i can't get the correct syntax.

The script  worked with the "show hosts" command but with "crypto map" one,   there is no output

Here is my script :

event manager applet IP

event none

action 1.0 cli command "show crypto map | include Peer"

action 1.5 regexp " ([0-9\.]+)" $_cli_result match ip_2

action 2.0 puts "$ip_2"

Can anyone help me?

Correct Answer
Joseph Clarke Thu, 05/17/2012 - 07:18

I don't know what the output looks like off the top of my head, but I do know you're missing the enable command.  Add:

action 0.5 cli command "enable"

Actions

Login or Register to take actions

This Discussion

Posted May 14, 2012 at 6:32 AM
Stats:
Replies:4 Avg. Rating:5
Views:932 Votes:0
Shares:0
Categories: Network Management
+

Related Content

Discussions Leaderboard