
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2016 03:56 AM
hi all,
I need to do an EEM script that when I do a "show ip interface brief | ex unassigned" it will list just the IP address.
Here is the output of my "show ip interface brief | ex unassigned"
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 30.1.1.2 YES manual up up
Serial2/0 40.1.1.2 YES manual up up
Loopback1 3.3.3.3 YES manual up up
heres my current script, it only prints 30.1.1.2. Why doesnt it match the other IP addresses ?
event manager applet 10
event none sync yes
action 1 cli command "en"
action 2 cli command "show ip int br | ex una"
action 3 regexp "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" "$_cli_result" ip
action 5 puts "$ip"
I want the output to be
30.1.1.2
40.1.1.2
3.3.3.3
Something like that.
Thanks,
Jonathan
Solved! Go to Solution.
- Labels:
-
EEM Scripting
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2016 05:33 PM
EEM needs to iterate over the output and extract the ip address.
action 010 cli command "enable"
action 020 cli command "show ip int brief | ex unass"
action 030 foreach line "$_cli_result"
action 040 regexp "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" "$line" ip
action 045 if $_regexp_result eq "1"
action 050 puts "$ip"
action 060 end
action 070 end
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2016 05:33 PM
EEM needs to iterate over the output and extract the ip address.
action 010 cli command "enable"
action 020 cli command "show ip int brief | ex unass"
action 030 foreach line "$_cli_result"
action 040 regexp "([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)" "$line" ip
action 045 if $_regexp_result eq "1"
action 050 puts "$ip"
action 060 end
action 070 end

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2016 07:38 PM
Thanks Daniel. Works like a charm :)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 10:09 AM
Hi Daniel,
I see you provided this EEM script ( LONG TIME AGO) to extract IP addresses which works wonderfully.
Is it possible to have each extracted IP address assigned to a different variable that I can call later on in my EEM script???
Thank you
Frank
