Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script to parse a log file, send only contents within delimiter

Status
Not open for further replies.

moogeboo

MIS
Aug 7, 2003
28
US
Hi,

Am fairly new to vbscript, and was wondering what is the best way to do the following: Parse a log file that essentially is divided among sections. Each section has data that needs to be sent to an email address in that particular section. Here is the format of the data file which includes 2 sections:


XXXX
415-221-2422
Email: mjordan@toys.com

Company.com
101 United Center Way
Chicago, IL 86221


7/14/2004

EMAIL TEST CUSTOMER
Toys.com
1 main street
New York, NY 21232


This is a test that we received your order.

This is a verification email. Your order number is 1211. Thank you.
XXXX
510-222-1400
Email: spippen@houses.com.com

Company.com
101 United Center Way
Chicago, IL 86221

7/14/2004
EMAIL TEST CUSTOMER
Houses.com
77 D street
Portland, OR 76542


This is a test that we received your order.

This is a verification email. Your order number is 9255. Thank you.
XXXX


So, essentially, what I have is one long log file, with the delimiter of XXXX. Any information between the XXXX, I'd like to include in the email. Is this possible to parse to find the email address in each section, send it to that user, then include everything within the delimiter of XXXX that pertains to only that user in the email? What i'm struggling with is how to separate only the information between the delimiters for each email.

Thanks a lot for any hints and methods.

 
And what have you so far ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Here is a scratch sample outline. Thanks for any input you may have....

Option Explicit
'*
'* Declare Constants
'*
Const cVBS = "emails.vbs"
Const cTXT = "emails.txt"
'*
'* Delare Variables
'*
Dim strMSG
Dim arrOTF
Dim strOTF
Dim intOTF
Dim arrTXT
Dim intTXT
Dim strTXT
Dim strWHO
'*
'* Delare Objects
'*
Dim objFSO
Dim objOTF
'*
'* Test File
'*
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FileExists(cTXT) Then
MsgBox "Input File Not Found!",vbExclamation,cVBS
WScript.Quit
End If
'*
'* Read File
'*
Set objOTF = objFSO.OpenTextFile(cTXT,1)
strOTF = objOTF.ReadAll
arrOTF = Split(strOTF,"XXXX")
Set objOTF = Nothing
'*
'* Loop File
'*
For intOTF = 0 To UBound(arrOTF)
If arrOTF(intOTF) <> "" Then
arrTXT = Split(arrOTF(intOTF),vbCrLf)
strWHO = ""
'*
'* Loop Data
'*
For intTXT = 0 To UBound(arrTXT)
strTXT = arrTXT(intTXT)
If Left(strTXT,7) = "Email: " Then
strWHO = Mid(strTXT,8)
End If
Next
strMSG = strWHO & vbCrLf & vbCrLf
strMSG = strMSG & arrOTF(intOTF)
MsgBox strMSG,vbInformation,cVBS
End If
Next
'*
'* Destroy Objects
'*
Set objFSO = Nothing
 
What is this not doing that you want it to do?

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
I'm in the process of refining this..I'll let you know what the outcome is...

thanks...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top