Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 netmiko: print out specific line matches with 'Cisco IOS Software' in sh ver output
#1
This is sample output of Cisco Switch show version command.

    Switch#show version
    Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE, RELEASE SOFTWARE (fc1)
    Technical Support: http://www.cisco.com/techsupport
    Copyright (c) 1986-2012 by Cisco Systems, Inc.
Objective: If string Cisco IOS Software is found in show version output, I would like to print the whole line.

To make it easier to understand, let me put show version output in variable shvar

    shvar = '''
    Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE, RELEASE SOFTWARE (fc1)
    Technical Support: http://www.cisco.com/techsupport
    Copyright (c) 1986-2012 by Cisco Systems, Inc.
    '''
Search with if

    >>> if 'Cisco IOS Software' in shvar:
    ...     print('Found ... print line')
    ... 
    Found ... print line
    >>> 
Or Search with find

    >>> if shvar.find('Cisco IOS Software') > 0:
    ...     print('Found ... print line')
    ... 
    Found ... print line
    >>> 
The question is how do I print the line matches with 'Cisco IOS Software'?

Desired Output

    Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE, RELEASE SOFTWARE (fc1)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Netmiko Program ssh from the Jumpssh ( host -> Jumphost -> Network Device matya0403 3 467 Jul-31-2020, 08:22 AM
Last Post: dtw
  Connect to device without paramiko/netmiko modules kang18 3 361 Jun-05-2020, 10:54 AM
Last Post: Larz60+
  Netmiko timing out after sending command c7borg 0 1,935 Mar-25-2020, 04:53 PM
Last Post: c7borg
  netmiko connecting to arista devices. dan1962 0 614 Feb-07-2020, 09:23 PM
Last Post: dan1962
  GNS3 telnet from bash terminal to virtual cisco router marienbad 2 1,186 Feb-24-2019, 07:55 AM
Last Post: marienbad
  How to get specific output on interface? searching1 3 869 Dec-31-2018, 01:29 AM
Last Post: Larz60+
  Python script for show commands-CISCO Devices babbarsher 1 7,207 Dec-13-2017, 11:44 PM
Last Post: Larz60+

Forum Jump:


Users browsing this thread: 1 Guest(s)