2017-04-25 10 views
1

現在、エラーログの内容全体をユーザーに電子メールで送信するVBSCRIPTがありますが、 「データが読み込まれました」と表示されたら、Error.logを電子メールで送信します。そうでない場合は、ログを添付して「ロードは成功しました」というメッセージを送信しないでください。 ご協力いただければ幸いです!これまでのError.logVBSCRIPT:ファイル内のテキストを検索し、テキストが見つかった場合にメールを送信

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 

スクリプトの

内容:

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 = "[email protected]" 
objMessage.To = "[email protected]" 

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 
+0

正確に何か問題がありますか? –

+0

エラーログに「見つかったデータを読み込む」という単語を検索するためのロジックを取得しようとしています。存在する場合は、電子メールに添付して誰かに送信してください。存在しない場合は、添付ファイルなしで電子メールを送信してください。 – user7571572

答えて

1

InStr functionは別の内の1つの文字列が最初に現れる位置を返します。例:

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 = "[email protected]" 
objMessage.To  = "[email protected]" 
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 

Sending email with CDOも読んでください。

+0

それはそれをしました。ありがとう! – user7571572

関連する問題