I have a script that takes all Windows Services and filters only the ones that have MSSQL and then I get seed the name of the services as shown below:
ButIneedtogetArrayvaluesandcomparethemwithaspecificvalue(thisismyproblemhere)whenIprintthearrayandthelocationIwant(ws1 ) it gives me this return:
Myquestionis:WhyisthisoccurringwhenI'mtaking1arrayhome?
Followthecode
importpsutil,reimportnumpyasnp#withopen('C:\Zabbix\Install\Texto.txt','w+')asarq:#arq.writelines(str(list(psutil.win_service_iter())))s=str(list(psutil.win_service_iter()))s=s.split()x=0y=0j=0ws=[]foritemins:if'MSSQL'ins[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