first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

DTS ActiveX Script Task: Formatting an Apache Log File; Visual Basic ActiveX Script; Data Transformation Services

'********************************************************************** ' Visual Basic ActiveX Script '************************************************************************ Function Main() Dim objFileSys : Set objFileSys = CreateObject("Scripting.FileSystemObject") Dim vPath : vPath = DTSGlobalVariables("gRootLogPath").Value Dim objInStream Dim objOutStream Dim vWrite, vLine

Set objInStream = objFileSys.OpenTextFile(vPath & "raw.txt")
Set objOutStream = objFileSys.CreateTextFile(vPath & "log.txt")

'
'Apache "common" log file: host ident authuser date request status bytes
'
Do Until objInStream.AtEndOfStream
    vWrite = false
    vLine = objInStream.ReadLine

    If Instr(1,vLine,"/ HTTP") > 0 _
        Or Instr(1,vLine,".css HTTP") > 0 _
        Or Instr(1,vLine,".exe HTTP") > 0 _
        Or Instr(1,vLine,".html HTTP") > 0 _
        Or Instr(1,vLine,".js HTTP") > 0 _
        Or Instr(1,vLine,".mov HTTP") > 0 _
        Or Instr(1,vLine,".mp3 HTTP") > 0 _
        Or Instr(1,vLine,".pdf HTTP") > 0 _
        Or Instr(1,vLine,".swf HTTP") > 0 _
        Then

        If Instr(1,vLine,"not_found.html HTTP") = 0 _
            And Instr(1,vLine, """GET" & Space(1)) > 0 _
            Then vWrite = true

    End If

    If CBool(vWrite) Then objOutStream.WriteLine(vLine)
Loop

objInStream.Close
objOutStream.Close

Set objInStream = Nothing
Set objOutStream = Nothing
Set objFileSys = Nothing

Main = DTSTaskExecResult_Success

End Function

mod date: 2003-12-04T19:51:27.000Z