我正在尝试构建此脚本以检查远程服务器上的文件是否包含设置的后缀,即 IE .ok、.err、.log。我不知道为什么我得到了我的回报
"('\\\\THPNWSS5\\d$\\DA$Utils\\log\\networker', [], ['P3EWS.err']) nothing is equal
“
我知道我的 try 语句有问题,但我看不到它。
chkbkpstats = csv.reader(file('c://temp//networkerservers1.csv'))
srvrs = []
for row in chkbkpstats:
srvrs.append({'Name' : row[0], 'Instance' : row[1]})
for srvr in srvrs:
srvrName = (srvr['Name'])
srvrInst = (srvr['Instance'])
w2k3chk = r'\\%s\d$\DA$Utils\log\networker' % srvrName
w2k8chk = r'\\%s\c$\ProgramData\folder\DA$Utils\log\networker' % srvrName
try:
c = wmi.WMI(srvr['Name'])
except:
print 'Error connecting to %s to check OS version' % srvrName
else:
osVer = c.Win32_OperatingSystem()[0].Caption
if '2003' in osVer:
for file in os.walk(w2k3chk):
print file
try:
if srvrInst == srvrInst + ".log":
print 'The Backup for %s on %s still running' % (srvrInst, srvrName)
if srvrInst == (srvrInst + ".ok"):
print 'Completed Successfully'
if srvrInst == (srvrInst + ".err"):
print 'Backup failed'
except:
print 'nothing is equal'
#print '%s is w2k3' % srvr['Name']
elif '2008' in osVer:
print '%s is w2k8' % srvr['Name']