Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started.

New Member

List interface names only without any additional information.

Hey All,

I'm wanting to create an applet that lists all non trunk ports on a switch, however I need the interface name only, I don't want the interface description, status, VLAN etc. Does anyone have any idea if its possible? 

Cheers,
BennyV       

Cheers, BennyV
  • EEM Scripting
1 ACCEPTED SOLUTION

Accepted Solutions
Cisco Employee

List interface names only without any additional information.

This won't give you non-trunk ports.  It will give you all ports.  And you likely want:

action 101 foreach line $_cli_result "\n"

action 110 regexp "^(.*Ethernet[^ ]+) " $line match intf

action 150 if $_regexp_result eq 1

action 160 puts "*$intf*"

action 170 end

action 180 end

4 REPLIES
New Member

List interface names only without any additional information.

Just to add I was hoping something like this would help.

event manager applet get_if

event none

action 100 cli command "show ip interface brief"

action 110 regexp " FastEthernet\d\/\d\/\d* " $_cli_result result

action 150 if $_regexp_result eq 1

action 160  puts "*$result*"

action 170 else

action 180  puts "No Results"

action 190 end

But the regex does not match for whatever reason.

Cheers, BennyV
Cisco Employee

List interface names only without any additional information.

This won't give you non-trunk ports.  It will give you all ports.  And you likely want:

action 101 foreach line $_cli_result "\n"

action 110 regexp "^(.*Ethernet[^ ]+) " $line match intf

action 150 if $_regexp_result eq 1

action 160 puts "*$intf*"

action 170 end

action 180 end

New Member

Re: List interface names only without any additional information

That's perfect, you've put me in the right direction. Thank You!

By the way, massive fan mate!

Cheers, BennyV
New Member

List interface names only without any additional information.

So this was to update all non trunk ports with some new QoS Config across multiple stacks. We have multiple trunk ports on each switch, so a range command was unlikley to work. This runs a "show interface status | e trunk" then for each result applies the config on the device. Its not the cleanest way to do this but it was sucessful.

event manager applet get_if

event none maxrun 60.00

action 100 cli command "show int status | e trunk"

action 120 foreach line $_cli_result "\n"

action 130 regexp "^(.*Fa[^ ]+|.*Gi[^ ]+) " $line match intf

action 140 if $_regexp_result eq 1

action 150 cli command "enable"

action 151 cli command "config t"

action 152 cli command "interface $intf"

action 153 cli command "no auto qos voip cisco-phone"

action 154 cli command "mls qos trust device cisco-phone"

action 155 cli command "auto qos trust cos"

action 156 puts "Update Sucessful $intf"

action 170 end

action 180 end

end

event manager run get_if

Cheers, BennyV
478
Views
0
Helpful
4
Replies