Hi Guys,
I have a problem.
I wolud like to write a script meet requirements:
Script must parse logfile for string ">>ZIP", create new text file with date-based name and copy every line which contains string "Connector".
HELP, PLEASE!!!
I wrote script to parse logfile.
I wrote script to create text file data-based name.
But: I can't write data to this plik. What Can I do wrong?
How to combine this 2 script?
script to parse logfile?
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ParserIIS\ex091218.log", 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine, "ScomConnector") <> 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(C:\ParserIIS\write.txt", 2)
objFile.Write strNewContents
objFile.Close
script to create data-based named file:
Option Explicit
On Error Resume Next
Dim fsoObject, open_File, target_File, thisday
Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ParserIIS\ex091218.log", 1)
today_date()
target_File = "C:\ParserIIS\ex" & thisday & ".txt"
Function Today_Date()
thisday=Right(Year(Date),2) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2)
End Function
Open_My_File()
Close_my_File()
Function Open_My_File()
If (fsoObject.FileExists(target_File)) Then
Set open_File = fsoObject.OpenTextFile(target_File, 8)
Else
Set open_File = fsoObject.OpenTextFile(target_File, 2, "True")
End If
End Function
Function Close_My_File()
open_File.Close()
End Function
I have a problem.
I wolud like to write a script meet requirements:
Script must parse logfile for string ">>ZIP", create new text file with date-based name and copy every line which contains string "Connector".
HELP, PLEASE!!!
I wrote script to parse logfile.
I wrote script to create text file data-based name.
But: I can't write data to this plik. What Can I do wrong?
How to combine this 2 script?
script to parse logfile?
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ParserIIS\ex091218.log", 1)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If InStr(strLine, "ScomConnector") <> 0 Then
strNewContents = strNewContents & strLine & vbCrLf
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile(C:\ParserIIS\write.txt", 2)
objFile.Write strNewContents
objFile.Close
script to create data-based named file:
Option Explicit
On Error Resume Next
Dim fsoObject, open_File, target_File, thisday
Set fsoObject = WScript.CreateObject("Scripting.FileSystemObject")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\ParserIIS\ex091218.log", 1)
today_date()
target_File = "C:\ParserIIS\ex" & thisday & ".txt"
Function Today_Date()
thisday=Right(Year(Date),2) & Right("0" & Month(Date),2) & Right("0" & Day(Date),2)
End Function
Open_My_File()
Close_my_File()
Function Open_My_File()
If (fsoObject.FileExists(target_File)) Then
Set open_File = fsoObject.OpenTextFile(target_File, 8)
Else
Set open_File = fsoObject.OpenTextFile(target_File, 2, "True")
End If
End Function
Function Close_My_File()
open_File.Close()
End Function