首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >VBSCRIPT:如果找到文本,在文件和电子邮件日志中查找文本

VBSCRIPT:如果找到文本,在文件和电子邮件日志中查找文本
EN

Stack Overflow用户
提问于 2017-04-25 17:53:08
回答 1查看 377关注 0票数 1

我目前有一个VBSCRIPT,它将获取错误日志的全部内容并将其发送给用户,但我希望对其进行修改,以便它搜索“遇到的加载数据”,如果它出现,则发送电子邮件给Error.log,否则,不要附加日志并发送消息"Load是成功的“。任何帮助都将不胜感激!

含量( Error.log )

代码语言:javascript
复制
2017-04-24 15:35:13,429 DEBUG [AIF]: CommData.updateWorkflow - END
2017-04-24 15:35:13,429 DEBUG [AIF]: AIFUtil.callOdiServlet - START
2017-04-24 15:35:13,451 INFO  [AIF]: EssbaseService.loadData - START
2017-04-24 15:35:13,507 DEBUG [AIF]: appId:3, appType:ESSBASE, mcFlag:false, dataLoadMethod:CLASSIC_VIA_EPMI, mDataFlowNode:LOCAL, textDataLoad:N, isFccsLoad:false, isJournalLoad:false
2017-04-24 15:35:13,508 DEBUG [AIF]: LOAD_METHOD:ESSFILE, LOAD_TYPE:DATA, EXPORT_MODE:STORE_DATA, CREATE_DRILL_REGION:false, PURGE_DATA_FILE:true, BATCH_SIZE:10000
2017-04-24 15:35:13,629 INFO  [AIF]: cloudServiceType: Planning, Resolved user name for application access: epm_default_cloud_admin
2017-04-24 15:35:14,816 DEBUG [AIF]: Obtained connection to essbase cube: Finance
2017-04-24 15:35:14,818 DEBUG [AIF]: Resolved essbase rule file name for loading: AIF0069
2017-04-24 15:35:14,819 DEBUG [AIF]: Fetching rule file from essbase server for data loading: AIF0069
2017-04-24 15:35:14,824 INFO  [AIF]: Starting executeDataRuleFile...
2017-04-24 15:35:14,826 DEBUG [AIF]: Locked rule file: AIF0069
2017-04-24 15:35:14,827 INFO  [AIF]: Getting load buffer for ASO data load...
2017-04-24 15:35:14,828 INFO  [AIF]: Initializing load buffer [1]
2017-04-24 15:35:14,828 INFO  [AIF]: Successfully initialized the load buffer
2017-04-24 15:35:14,828 INFO  [AIF]: Loading data into cube using data file...
2017-04-24 15:35:14,844 INFO  [AIF]: purge data file: /u03/inbox/outbox/AQCONSOL_930.dat
2017-04-24 15:35:14,845 INFO  [AIF]: The load buffer [1] has been closed.
2017-04-24 15:35:14,845 INFO  [AIF]: **Load data encountered** the following errors:
| Error: 3303 | A99999 | "A99999","01","Functional","L000","Default Version","C10010","P0000","J00000","FY16","G00","Actual","[YearTotal].[Q1].[Jan]",100 |
2017-04-24 15:35:14,845 INFO  [AIF]: Load data failed.
2017-04-24 15:35:14,846 DEBUG [AIF]: Unlocked rule file: AIF0069
2017-04-24 15:35:14,846 ERROR [AIF]: Load data failed.
2017-04-24 15:35:14,853 INFO  [AIF]: EssbaseService.loadData - END (false)
2017-04-24 15:35:14,871 DEBUG [AIF]: AIFUtil.callOdiServlet - END
2017-04-24 15:35:14,871 FATAL [AIF]: Error in CommData.loadData
Traceback (most recent call last):
  File "<string>", line 4769, in loadData
RuntimeError: false

到目前为止脚本:

代码语言:javascript
复制
fileEmail = "C:\Error.log"

intCount = 0  
Set objStream = objFSO.OpenTextFile(fileEmail)  
Do Until objStream.AtEndOfStream  
sline = objStream.Readline  
If intCount = 0 Then  
objMessage.Subject = sline  
Else  
strMessage = strMessage & sline & vbcrlf   
End If  
intCount = intCount + 1  
Loop  

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

strMessage = strMessage & vbcrlf

objMessage.From = "test@123.com" 
objMessage.To = "test@123.com" 

objMessage.TextBody = strMessage

objMessage.Configuration.Fields.Item _
("Microsoft URL") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = "smtp.secureserver.net"

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("Microsoft URL") = cdoBasic

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = ""

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("Microsoft URL") = ""

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = 465 

'Use SSL for the connection (False or True)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = True

'Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
objMessage.Configuration.Fields.Item _
("Microsoft URL") = 60

objMessage.Configuration.Fields.Update

objMessage.Send

Set objStream = Nothing

'Delete File when finished

objFSO.DeleteFile fileprocesslog, True
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-04-26 06:56:59

function返回一个字符串在另一个字符串中出现的第一个位置。例如,按以下方式适用:

代码语言:javascript
复制
sSearchFor   = "Load data encountered"
booFound     = False
sMessageSubj = "Log file empty"
fileEmail = "C:\Error.log"
intCount = 0
Set objStream = objFSO.OpenTextFile(fileEmail)  
Do Until objStream.AtEndOfStream  
  sline = objStream.Readline  
  If intCount = 0 Then  
    sMessageSubj = sline  
  Else  
    strMessage = strMessage & sline & vbcrlf   
  End If
  booFound = booFound  Or ( Instr( 1, sline, sSearchFor, vbTextCompare) > 0)
  intCount = intCount + 1  
Loop
objStream.Close

Set objMessage = CreateObject("CDO.Message")
objMessage.From    = "test@123.com" 
objMessage.To      = "test@123.com" 
objMessage.Subject = sMessageSubj
If booFound Then
  objMessage.AddAttachment fileEmail
  strMessage = strMessage & vbcrlf
Else
  strMessage = "Load was successful" & vbcrlf
End If
objMessage.TextBody = strMessage
' ''' remote SMTP server configuration section Begin '''
' '''        configure remote SMTP server here       '''
' objMessage.Configuration.Fields.Update
' ''' remote SMTP server configuration section End   '''
objMessage.Send

Const cdoAnonymous = 0 'Do not authenticate
Const cdoBasic = 1 'basic (clear-text) authentication
Const cdoNTLM = 2 'NTLM

也可以阅读http://www.paulsadowski.com/wsh/cdo.htm

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43617749

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档