Apr-20-2020, 05:52 AM
This is sample output of Cisco Switch show version command.
To make it easier to understand, let me put
Desired Output
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)
