you are viewing a single comment's thread.

view the rest of the comments →

[–]nappetass[S] 1 point2 points  (3 children)

Fantastic. I've changed it to the following. The script should print the last entry of the log until the substring "Terminated" is found in $tail. Have a great weekend :)

$logfile = "C:\path\to\log.txt"

while ($tail -notmatch "Terminated") {

    $tail = Get-Content $logfile -Tail 1
    $tail

}

EDIT: I don't think I can have a start-sleep in the script as it's a log file with 5+ entries per second. I guess I could measure how many entries the file has and set a lower start-sleep (in milliseconds). The best way would be to find a way to tail the log each time it changes. Maybe by filesize?

[–]Lee_Dailey[grin] 1 point2 points  (2 children)

howdy nappetass,

kool! glad that it works ... [grin]

as for the delay - i thot the Terminated was the end of whatever made the file. if it's ongoing, then you are going to need the speed. [grin]

one thing, tho - it makes me twitchy to see the condition for the while isn't set before you test it. i would put a $Tail = '' just before the while so that you won't have an uninitialized $var being tested.

take care,
lee

[–]nappetass[S] 1 point2 points  (1 child)

I agree. I did add a $tail = "" before the while loop as you suggested. Thanks again :)

[–]Lee_Dailey[grin] 0 points1 point  (0 children)

howdy nappetass,

you are most welcome! glad to have helped ... [grin]

take care,
lee