Oct-20-2018, 09:28 AM
(Oct-20-2018, 05:57 AM)alinaveed786 Wrote: I was able to achieve via below modifications. Thanks everyone for all the help and support
#!/usr/bin/python import re import subprocess s = subprocess.check_output(["opatch", "lsinventory"]) output = s.decode("utf-8") patches = [27923320, 27547329, 21463894, 12345, 99999] patches_found = set(re.findall(r'\b(?:%s)\b' % '|'.join(map(str, patches)), output)) patches_missing = set(map(str, patches)) - patches_found if patches_found: print('Patch', patches_found, "detected") if patches_missing: print("Patch", patches_missing, "missing")
You convert
patches
elements to strings twice - would not it have been easier to just define them as strings?!
Test everything in a Python shell (iPython, Azure Notebook, etc.)
- Someone gave you an advice you liked? Test it - maybe the advice was actually bad.
- Someone gave you an advice you think is bad? Test it before arguing - maybe it was good.
- You posted a claim that something you did not test works? Be prepared to eat your hat.