File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed
netmiko-interface-example Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change 4747 # Print the raw command output to the screen
4848 print (interface )
4949
50- # Use regular expressions to parse the output for desired data
51- name = re .search (r'interface (.*)' , interface ).group (1 )
52- description = re .search (r'description (.*)' , interface ).group (1 )
53- ip_info = re .search (r'ip address (.*) (.*)' , interface )
54- ip = ip_info .group (1 )
55- netmask = ip_info .group (2 )
56-
57- # Print the info to the screen
58- print ("The interface {name} has ip address {ip}/{mask}" .format (
59- name = name ,
60- ip = ip ,
61- mask = netmask ,
50+ try :
51+ # Use regular expressions to parse the output for desired data
52+ name = re .search (r'interface (.*)' , interface ).group (1 )
53+ description = re .search (r'description (.*)' , interface ).group (1 )
54+ ip_info = re .search (r'ip address (.*) (.*)' , interface )
55+ ip = ip_info .group (1 )
56+ netmask = ip_info .group (2 )
57+
58+ # Print the info to the screen
59+ print ("The interface {name} has ip address {ip}/{mask}" .format (
60+ name = name ,
61+ ip = ip ,
62+ mask = netmask ,
63+ )
6264 )
63- )
65+ except Exception :
66+ print ("There was an error, Loopback103 might not exist." )
You can’t perform that action at this time.
0 commit comments