-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathw7e2.py
More file actions
30 lines (26 loc) · 871 Bytes
/
Copy pathw7e2.py
File metadata and controls
30 lines (26 loc) · 871 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import re
f = open("ospf_single_interface.txt")
dict = {}
for line in f.readlines():
s_var = re.search(r"(.+) is up, line protocol is up", line)
if s_var:
dict['Int'] = s_var.group(1)
s_var = re.search(r"Internet Address (.+?), Area (.+?),", line)
if s_var:
dict['IP'] = s_var.group(1)
dict['Area'] = s_var.group(2)
s_var = re.search(r"Network Type (.+), Cost: (.+)", line)
if s_var:
dict['Type'] = s_var.group(1)
dict['Cost'] = s_var.group(2)
s_var = re.search(r"Hello (.+), Dead (.+?),", line)
if s_var:
dict['Hello'] = s_var.group(1)
dict['Dead'] = s_var.group(2)
print " Int:", dict['Int']
print " IP:", dict['IP']
print " Area:", dict['Area']
print " Type:", dict['Type']
print " Cost:", dict['Cost']
print "Hello:", dict['Hello']
print " Dead:", dict['Dead']