The following is my code:
with open("WinUpdates.txt") as f:
data=[]
for elem in f:
data.append(elem)
with open("checked.txt", "w") as f:
check=True
for item in data:
if "KB2982791" in item:
f.write("KB2982791\n")
check=False
if "KB2970228" in item:
f.write("KB2970228\n")
check=False
if "KB2918614" in item:
f.write("KB2918614\n")
check=False
if "KB2993651" in item:
f.write("KB2993651\n")
check=False
if "KB2975719" in item:
f.write("KB2975719\n")
check=False
if "KB2975331" in item:
f.write("KB2975331\n")
check=False
if "KB2506212" in item:
f.write("KB2506212\n")
check=False
if "KB3004394" in item:
f.write("KB3004394\n")
check=False
if "KB3114409" in item:
f.write("KB3114409\n")
check=False
if "KB3114570" in item:
f.write("KB3114570\n")
check=False
if check:
f.write("No faulty Windows Updates found!")
The "WinUpdates.txt" file contains a lot of lines like these:
http://support.microsoft.com/?kbid=2980245 RECHTS Update
KB2980245 NT-AUTORITÄT\SYSTEM 8/18/2014
http://support.microsoft.com/?kbid=2981580 RECHTS Update
KB2981580 NT-AUTORITÄT\SYSTEM 8/18/2014
http://support.microsoft.com/?kbid=2982378 RECHTS Security Update KB2982378 NT-AUTORITÄT\SYSTEM 9/12/2014
http://support.microsoft.com/?kbid=2984972 RECHTS Security Update KB2984972 NT-AUTORITÄT\SYSTEM 10/17/2014
http://support.microsoft.com/?kbid=2984976 RECHTS Security Update KB2984976 NT-AUTORITÄT\SYSTEM 10/17/2014
http://support.microsoft.com/?kbid=2984981 RECHTS Security Update KB2984981 NT-AUTORITÄT\SYSTEM 10/16/2014
http://support.microsoft.com/?kbid=2985461 RECHTS Update
KB2985461 NT-AUTORITÄT\SYSTEM 9/12/2014
http://support.microsoft.com/?kbid=2987107 RECHTS Security Update KB2987107 NT-AUTORITÄT\SYSTEM 10/17/2014
http://support.microsoft.com/?kbid=2990214 RECHTS Update
KB2990214 NT-AUTORITÄT\SYSTEM 4/16/2015
http://support.microsoft.com/?kbid=2991963 RECHTS Security Update KB2991963 NT-AUTORITÄT\SYSTEM 11/14/2014
http://support.microsoft.com/?kbid=2992611 RECHTS Security Update KB2992611 NT-AUTORITÄT\SYSTEM 11/14/2014
http://support.microsoft.com/?kbid=2993651 RECHTS Update
KB2993651 NT-AUTORITÄT\SYSTEM 8/29/2014
http://support.microsoft.com/?kbid=2993958 RECHTS Security Update KB2993958 NT-AUTORITÄT\SYSTEM 11/14/2014
But when I execute my code, it says that it has not found any of those updates? Even though I know that it should find 4. I wrote the "data" list into a new text file, but there it seems everything alright?
Why do you think my code does not work?
WinUpdates.txtfile, I get multiple results inchecked.txt. What output are you getting, and what output do you want?checked.txt.[Decode error - output not utf-8]. So, it looks like a unicode problem. I'm running Python2. @PM2Ring: I'm guessing you're on Python3?catcommand in a shell which uses UTF-8 encoding.