0
I have a script that takes all the Windows Services and filters only those that have MSSQL and then take the name of the services as image below:
But I need to take the values of the Array and compare with a specific value (this is my problem) when print the array and the location I want (Ws1) he gives me that return:
My question is: The pq this occurring being that I’m taking the 1 house of the array?
Follows the code
import psutil, re
import numpy as np
#with open('C:\Zabbix\Install\Texto.txt', 'w+') as arq:
# arq.writelines (str(list(psutil.win_service_iter())))
s =str(list(psutil.win_service_iter()))
s = s.split()
x = 0
y = 0
j = 0
ws = []
for item in s:
if 'MSSQL' in s[x]:
v = str(s[x])
v = v.replace('(', '')
v = v.replace(')', '')
v = v.split("'")
ws = str(list(filter(lambda w: w.startswith('MSSQL'), v)))
print(ws[1])
x += 1
Got it though, when I shoot I can’t capture the values by being a class of the LIB PSUTIL... that’s what "broke me," so I’m kind of forced to do this
– user68537
@Wallacebrunogentil classes of this lib can have their values captured yes... Try to inspect the class, use the command
dir()
orhelp()
, look for examples - convert to string is the wrong way to do and will bring you trouble every time.– nosklo