Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

How to receive 2 or more IP from interface ???

!Buenas deas Amigos! I want to get from interface all IP addresses. For example I have vlan xx sh run int vlan xx interface VlanXX ip address 172.16.1.1 255.255.255.0 secondary ip address 10.10.10.1 255.255.255.0 secondary ip address 192.168.1.1 255.255.255.0 I have created EEM Applet event manager applet getip event none sync yes action 1.0 cli command "enable" action 2.0 cli command "sh run int vlan 11" action 2.2 regexp "ip address ([0-9\.]+)" "$_cli_result" _match _ipadd action 2.3 puts "$_ipadd" So I have got ONLY FIRST IP address 172.16.1.1 Dear ALL help me PUTS all addresses from the script . PLEASEeeeee
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

You can iterate: action 2.1

You can iterate:

 

action 2.1 foreach line $_cli_result "\n"

action 2.2 regexp "ip address ([0-9\.]+)" "$_cli_result" match ipadd

action 2.3 if $_regexp_result eq 1

action 2.4 puts $ipadd

action 2.5 end

action 2.6 end

3 REPLIES
New Member

Sorry Its stupid BUG

Sorry Its stupid Cisco BUG !

Buenas deas Amigos!

I want to get from interface all IP addresses.

For example I have vlan xx

   sh run int vlan xx

   interface VlanXX

   ip address 172.16.1.1 255.255.255.0 secondary

   ip address 10.10.10.1 255.255.255.0 secondary

   ip address 192.168.1.1 255.255.255.0

I have created EEM Applet

    event manager applet getip

      event none sync yes

      action 1.0 cli command "enable"

      action 2.0 cli command "sh run int vlan 11"

      action 2.2 regexp "ip address ([0-9\.]+)" "$_cli_result" _match _ipadd

      action 2.3 puts "$_ipadd"

So I have got ONLY FIRST IP address 172.16.1.1

Dear ALL help me PUTS all addresses from the script . PLEASEeeeee

 

Cisco Employee

You can iterate: action 2.1

You can iterate:

 

action 2.1 foreach line $_cli_result "\n"

action 2.2 regexp "ip address ([0-9\.]+)" "$_cli_result" match ipadd

action 2.3 if $_regexp_result eq 1

action 2.4 puts $ipadd

action 2.5 end

action 2.6 end

New Member

Thank you Joseph !!!The key "

Thank you Joseph !!!

The key "\n" is wonderful  :-)

I attempted to use "foreach" but without "\n"

107
Views
0
Helpful
3
Replies
CreatePlease to create content