cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
777
Views
5
Helpful
3
Replies

Expect script show run int g0/0.x

sas2k3001
Level 1
Level 1

Hello,

 

I'm looking for except script 

That will able to run command show run int g0/0.x on 4,094 vlan's

 

 

ThanksRouting

 

 

3 Replies 3

Giuseppe Larosa
Hall of Fame
Hall of Fame

Hello @sas2k3001 ,

no router can support 4,094 VLAN based subinterfaces on the same physical interface ( at least at branch/enterprise level)

 

However, you can collect the output of

show ip interface brief  | inc gi0/0\.

inside the script

in this way  you will find a list of all defined subinterfaces the \.  tells that you are looking for literal . character and to avoid to consider it a special character in a regular expression.

Once you have the list of defined subinterfaces you can run for each of them

show run int gi0/0.<value>

 

Hope to help

Giuseppe

 

Jon Marshall
Hall of Fame
Hall of Fame

 

As suggested in your other thread you could use Python and Netmiko. 

 

The following is a very basic script that would do what you want (it has no error checking etc) - 

 

#!/home/netadmin/ntc/bin/python

import re
from netmiko import ConnectHandler

swp = ConnectHandler(device_type='cisco_ios',
                     host='172.30.2.2',
                     username='<your username>',
                     password='<your password>',
                     secret='<enable password>' )

swp.enable()
results = swp.send_command('sh run')
swp.disconnect()

for intf in re.findall(r'(interface Gigabit0/0\.\d+[^!]+)', results, re.DOTALL):
    print(intf)

 

You would obviously need to set the IP,  the username and the passwords. 

 

Jon

Dan Frey
Cisco Employee
Cisco Employee

Another option is to use the tcl shell to dynamically discover all the interfaces associated with Gig0/0.XXXX and run the show command by pasting this into exec level of the router cli.

 

term length 0
tclsh
set lines [exec "sh ip int brief | inc GigabitEthernet0/0"]
    foreach line [split $lines "\n"] {
        if [regexp {(GigabitEthernet0\/0\.[0-9]+)} $line match interface ] {
            show interface $interface   
        }
    }

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: