Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Parsing Line of Text Based On A Condition

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,255
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Parsing Line of Text Based On A Condition
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Parsing Line of Text Based On A Condition - 7/8/2001 8:51:59 AM   
  century

 

Posts: 10
Score: 0
Joined: 6/7/2001
From: USA
Status: offline
Hi,

I've written a script that reads a log file. One input line of this log file
is as follows:

10.11.130.80 - - [01/May/2001:13:52:59 -0600] "GET
/insuredacct/index.cfm HTTP/1.0" 200 355

I'm trying to split up this one string into multiple string variables to be
used later to populate a database.

However, I'm a little stumped on how to read a portion of the buffer,
stop reading when I find a space, assign what I've read so far to a
string variable, then pick back up reading where I left off.

For example, here's how I want my assignment:

strIP = 10.11.130.80
strId = -
strUser = -
strTime = [01/May/2001:13:52:59 -0600]
strRequest = "GET /insuredacct/index.cfm HTTP/1.0"
strResult = 200
strBytes = 355


Here's the code I have, but so far I'm only able to read an entire line
of my file and determine if I have a '.' in the line.

<%
LogFile = "d:\inetpub\wwwroot\logs\nc010501.txt"

Set LogFileObj = Server.CreateObject("Scripting.FileSystemObject")
Set LogTextFile = LogFileObj.OpenTextFile(LogFile)

dim strBuffer
dim strIP, strID, strUser, strTime, strRequest, strResult, strBytes

strBuffer=LogTextFile.Readline


'***********************************************
' BEGINNING TO SPLIT UP THE FILE INTO VARIABLES
'***********************************************
'determine if there's a . in the buffer
if instr(strBuffer,".") then
response.write "<br>" & "Contains a '.' ." & "<br>"
else
response.write "<br>" & "Does not contain a '.' ." & "<br>"
end if

%>


Any help anyone can provide would be much appreciated.

Thanks,
 
 
Post #: 1
 
 Re: Parsing Line of Text Based On A Condition - 7/8/2001 8:53:12 AM   
  aspprogrammer

 

Posts: 10
Score: 0
Joined: 6/9/2001
From: Belgium
Status: offline
dim theArray(), theString

theString = "10.11.130.80 - - [01/May/2001:13:52:59 -0600] GET
/insuredacct/index.cfm HTTP/1.0 200 355"

theArray = split(theString, " ")

will give you an array with each element containing the successive bits
of that string minus the spaces -- i.e. you are splitting the string with a
space as the delimeter.

(in reply to century)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Parsing Line of Text Based On A Condition Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts