|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Parsing the appended data of log file in real timeHello all,
I have a log file that is appended to in real time by an application. I would like to write a loop in vb.net that reads new entires and parses them. I can get my application to open a file and read it all the way through but I can not get it to continue looping after the file is finished. I am trying to get the new additions to the log file to be displayed in a textbox in real time. Any help is greatly appreciated. My guess is that you are opening the file and leaving it open while
you look for new data that is appended to the file by the other software. This will not work because if you do not close the file and re-open it, you will never know about any new data that is written to it by the other program. You may also be blocking the other program fom writing to the file. The way that I would do things would be to check for the file to see if it exists. If it does, then read in all the data from the file and then append it all to the end of a second log file and then delete the original log file. (I assume that the program that creates the log file in the first place will automatically create the file if it does not exist). Then all you need to do is to use a timer to check for the original file every so often and if it exists, read it in, append it to the second log file and delete the original exactly as described above. If the file does not exist, then do nothing. Show quoteHide quote On 11 Jun 2006 20:25:08 -0700, "Paulers" <SuperG***@gmail.com> wrote: >Hello all, > >I have a log file that is appended to in real time by an application. I >would like to write a loop in vb.net that reads new entires and parses >them. I can get my application to open a file and read it all the way >through but I can not get it to continue looping after the file is >finished. I am trying to get the new additions to the log file to be >displayed in a textbox in real time. Any help is greatly appreciated. Hi Thomas,
Actually another application is writing to the log file. I just need my application to continue looping displaying anything that should enter into the log file. I found a visual basic script that is doing the same thing. I just need to figure out how to do it in vb.net. CAn anyone help? 'scriptInAction is the control vairiable for the do util loop while 'scriptInAction is 1 the do loop continues 'either exit do or set scriptInAction to another number to end 'the script's loop ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' dim scriptInAction scriptInAction = 1 currentLine = "0" Do While scriptInAction = 1 If logFile.AtEndOfStream <> True Then currentLine = logFile.ReadLine If InStr (currentLine, exitScript) Then scriptInAction = 0 End If If InStr (currentLine, masterName) And InStr (currentLine, commandPhrase) Then workingLine = StrReverse (currentLine) workingLine2 = Split (workingLine, commandDelimiter, 1, 1) workingLine = StrReverse (workingLine2) WshShell.SendKeys ("/" & workingLine & "~") End If End If WScript.echo currentLine WScript.Sleep 50 currentLine = "holding" Loop Thomas Lutz wrote: Show quoteHide quote > My guess is that you are opening the file and leaving it open while > you look for new data that is appended to the file by the other > software. This will not work because if you do not close the file and > re-open it, you will never know about any new data that is written to > it by the other program. You may also be blocking the other program > fom writing to the file. > > The way that I would do things would be to check for the file to see > if it exists. If it does, then read in all the data from the file and > then append it all to the end of a second log file and then delete the > original log file. (I assume that the program that creates the log > file in the first place will automatically create the file if it does > not exist). Then all you need to do is to use a timer to check for the > original file every so often and if it exists, read it in, append it > to the second log file and delete the original exactly as described > above. If the file does not exist, then do nothing. > > > On 11 Jun 2006 20:25:08 -0700, "Paulers" <SuperG***@gmail.com> wrote: > > >Hello all, > > > >I have a log file that is appended to in real time by an application. I > >would like to write a loop in vb.net that reads new entires and parses > >them. I can get my application to open a file and read it all the way > >through but I can not get it to continue looping after the file is > >finished. I am trying to get the new additions to the log file to be > >displayed in a textbox in real time. Any help is greatly appreciated. Hello Paulers,
Check out the Stream.Peek function. When peek doesnt return any data then sit in an idle loop till it does.. then continue blithly on your merry way. -Boo Show quoteHide quote > Hi Thomas, > > Actually another application is writing to the log file. I just need > my application to continue looping displaying anything that should > enter into the log file. > > I found a visual basic script that is doing the same thing. I just > need to figure out how to do it in vb.net. CAn anyone help? > > 'scriptInAction is the control vairiable for the do util loop while > 'scriptInAction is 1 the do loop continues > 'either exit do or set scriptInAction to another number to end > 'the script's loop > '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' > ''''''''''''' > dim scriptInAction > scriptInAction = 1 > currentLine = "0" > Do While scriptInAction = 1 > If logFile.AtEndOfStream <> True Then > currentLine = logFile.ReadLine > If InStr (currentLine, exitScript) Then > scriptInAction = 0 > End If > If InStr (currentLine, masterName) And InStr (currentLine, > commandPhrase) Then > workingLine = StrReverse (currentLine) > workingLine2 = Split (workingLine, commandDelimiter, 1, 1) > workingLine = StrReverse (workingLine2) > WshShell.SendKeys ("/" & workingLine & "~") > End If > End If > WScript.echo currentLine > WScript.Sleep 50 > currentLine = "holding" > Loop > Thomas Lutz wrote: > >> My guess is that you are opening the file and leaving it open while >> you look for new data that is appended to the file by the other >> software. This will not work because if you do not close the file and >> re-open it, you will never know about any new data that is written to >> it by the other program. You may also be blocking the other program >> fom writing to the file. >> >> The way that I would do things would be to check for the file to see >> if it exists. If it does, then read in all the data from the file and >> then append it all to the end of a second log file and then delete >> the original log file. (I assume that the program that creates the >> log file in the first place will automatically create the file if it >> does not exist). Then all you need to do is to use a timer to check >> for the original file every so often and if it exists, read it in, >> append it to the second log file and delete the original exactly as >> described above. If the file does not exist, then do nothing. >> >> On 11 Jun 2006 20:25:08 -0700, "Paulers" <SuperG***@gmail.com> wrote: >> >>> Hello all, >>> >>> I have a log file that is appended to in real time by an >>> application. I would like to write a loop in vb.net that reads new >>> entires and parses them. I can get my application to open a file and >>> read it all the way through but I can not get it to continue looping >>> after the file is finished. I am trying to get the new additions to >>> the log file to be displayed in a textbox in real time. Any help is >>> greatly appreciated. >>>
Error converting FILETIME to DateTime
line breaks richtextbox changing fontstyles for selected text is it possible to get delegates from properties directly? control types XML-RPC Tabindex is driving me nuts!!! richtextbox selectedtext bold upper .... how to find out Screen coordinates of selected datagridview cells left and top borders actions done twice but only one trigger? |
|||||||||||||||||||||||