Paul said:
Hello, KayZer:
On Thu, 17 Feb 2005 14:40:08 -0300: you wrote...
KS> In Linux Shell, the 'tail -f' command can be used to show an log file,
KS> as lines are beeing added, dynamically. As the linnes are added to the
KS> end of file, the lines are showed.
KS> This can be done with MS logparser?
KS>
Logparser runs a single query. Try tail from
http://unxutils.sourceforge.net/
or
GUI based tail here
http://tailforwin32.sourceforge.net/
Regards, Paul R. Sadowski [MVP].
yesterday i wrote a script that does exactly that
' Purpose: monitor a file and report the changed lines when modified
' similar to unix's tail -f
' Programmer: (e-mail address removed)
' Last Modified: 04.06.05
' Usage: Drag and drop a file onto the script.
numARGS = ((Wscript.Arguments.count) - 1)
sleepTime = 5
nSecs = sleepTime * 100
' get the filename
for i = 0 to numARGS step 1
fileName = Wscript.Arguments(i)
next
currentSize = getFileSize(fileName)
currentNumLines = getLineCount(fileName)
set oFso = CreateObject("Scripting.FileSystemObject")
while 1
nSize = getFileSize(fileName)
if (nSize > currentSize) then
currentSize = nSize
Set ts = oFso.OpenTextFile(fileName, 1, False)
Set contentsDict = CreateObject("Scripting.Dictionary")
While Not ts.atendofstream
contentsDict.Add i, ts.ReadLine
i = i + 1
Wend
i = 0
ts.Close
Set ts = Nothing
numLines = contentsDict.Count
startLine = currentNumLines
for key = startLine to numLines step 1
tail = tail & VBCRLF & contentsDict(key)
next
' msgbox tail
wscript.echo tail
tail = ""
currentNumLines = getLineCount(fileName)
end if
WScript.Sleep nSecs
wend
Function getFileSize(filespec)
Dim fso, f, s
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile(filespec)
s = f.size
getFileSize = s
End Function
Function getLineCount(filespec)
v = 0
set p_oFso = CreateObject("Scripting.FileSystemObject")
set p_ts = p_oFso.OpenTextFile(filespec, 1, False)
Set p_contentsDict = CreateObject("Scripting.Dictionary")
While Not p_ts.atendofstream
p_contentsDict.Add v, p_ts.ReadLine
v = v + 1
Wend
getLineCount = p_contentsDict.Count
End Function