-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscanDir.py
More file actions
43 lines (35 loc) · 1.7 KB
/
Copy pathscanDir.py
File metadata and controls
43 lines (35 loc) · 1.7 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
import re
# try:
# entries = os.listdir(input("Which 'dir' would you like to scan?\nEnter here: ") + '/')
#
# print(entries)
# for entry in entries:
# print(entry)
# except:
# print("could not be found, try again")
input1 = input("Which 'dir' would you like to scan?\nEnter here: ")
with os.scandir(input1 + '/') as entries:
for count, entry in enumerate(entries, 1):
print(count, entry.name)
with os.scandir(input1 + '/') as entries1:
for count, entry1 in enumerate(entries1, 1):
with open(entry1, 'rt') as f:
contents = f.readlines()
#print(contents)
string_search = 'System image file is "flash:c3560cx-universalk9-mz.152-4.E6.bin"\n' #This string can be replaced in case a IOS change occurs; retrieve it from show version
oP1 = list(filter(lambda a: string_search in a, contents))
#print(oP1)
if string_search in oP1:
print(f"{count} <> {entry1.name} correct IOS installed$$$$$")
else:
print(f"{count} <> {entry1.name} does not have correct IOS installed!!!!!!")
# pattern = re.compile(r'^System image file is "flash:c3560cx-universalk9-mz.152-4.E6.bin"')
# matches = pattern.finditer(contents)
# for match in matches:
# print(match.group(0))
# if 'System image file is "flash:c3560cx-universalk9-mz.152-4.E6.bin"' in match.group(0):
# print(f"{entry1.name} correct IOS installed$$$$$")
# pass
# else:
# print(f"{entry1.name} does not have correct IOS installed!!!!!!")