我已经编写了Python脚本来执行类似的数据
我的脚本:
import os
import os.path
import re
import smtplib
from email.mime.text import MIMEText
infile = r"D:\i2Build\i2SchedulerReport.txt"
if os.path.isfile(infile) and os.access(infile, os.R_OK):
print "Scheduler report exists and is readable"
else:
print "Scheduler report is missing or is not readable"
sreport = {}
keep_phrases = ["Scheduler Running is failed"]
with open(infile) as f:
f = f.readlines()
for line in f:
for phrase in keep_phrases:
if phrase in line:
key,val=line.split(":")
sreport[key]=val.strip()
break
for k,v in sreport.items():
print k,'',v
in2npdvlnx45 => Scheduler Running is failed
bnaxpd01 => Scheduler Running is failed
md1npdaix15 => Scheduler Running is failed
bnaxpd04 => Scheduler Running is failed
bnwspd03 => Scheduler Running is failed
md1npdsun10 => Scheduler Running is failed
bn2kpd14 => Scheduler Running is failed
md1npdvbld02 => Scheduler Running is failed
bnhppd05 => Scheduler Running is failed
dlaxpd02 => Scheduler Running is failed
cmwspd02 => Scheduler Running is failed
我希望以上数据以表格格式执行,如下所示,它使用MIME导入模块或其他一些格式将输出表格式发送到邮件。我看到导入熊猫是有帮助的,但无法做到
预期输出:
in2npdvlnx45 Scheduler Running is failed
bnaxpd01 Scheduler Running is failed
md1npdaix15 Scheduler Running is failed
bnaxpd04 Scheduler Running is failed
bnwspd03 Scheduler Running is failed
md1npdsun10 Scheduler Running is failed
bn2kpd14 Scheduler Running is failed
md1npdvbld02 Scheduler Running is failed
bnhppd05 Scheduler Running is failed
dlaxpd02 Scheduler Running is failed
cmwspd02 Scheduler Running is failed