Skip to content

Instantly share code, notes, and snippets.

@bDrwx
Created February 11, 2019 10:04
Show Gist options
  • Save bDrwx/3e00af66e80940d67bd16f07e8072517 to your computer and use it in GitHub Desktop.
Save bDrwx/3e00af66e80940d67bd16f07e8072517 to your computer and use it in GitHub Desktop.
with open('SK-KN-USKARS-SW-CE-1.txt', 'r') as myfile:
data = myfile.read()
# Hostname
result = re.search(r'hostname (SK-\S+)\n', data)
print(result.group(1))
#Loopback interface
result = re.search(r'interface Loopback\d+\n.*ip address (\d+.\d+.\d+.\d+)', data)
print(result)
#SNMP RW and RO Access list
result = re.search(r'snmp-server community (.+) RO (.+)', data)
print(result.group(1))
print(result.group(2))
result = re.search(r'snmp-server host (\d+.\d+.\d+.\d+)', data)
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment