I don't believe you can grep from a tail -f, since the tail holds the output open until it is terminated.. the pipe would wait for a close. When I run the "tail -f file | grep something" at a command line, I get nothing at all. I get the same results with the DOS and Korn shells, btw.
At least, thats what appears to happen on my workstation with MKS Toolkit.
Here's my sample code (z.kix), which opens 3 windows.
"X.Kix" sits in an infinite loop writing to three files (since I don't have any other active files to monitor). It simulates your app writing to multiple log files.
"z.kix" kicks off the log generator (x.kix) and then initiates three windows to monitor the output. Once I invoke the window, I see tail displaying ALL of the lines written to the file - grep has no effect.
At least you know you aren't pulling hair out for no reason.. it's an O/S limitation. I can't get onto a *nix system now to confirm how it would work there..
Glenn
code:
; x.kix - simulate constant writing to 3 logfiles
Break ON
Srnd(@TICKS)
$STAT = "|","/","-","\"
$CNT = 0
while 1
$MSG = CStr(Rnd(5)) + ": some status message@CRLF"
$RTN = Open(4, "C:\Temp\File1", 5)
$RTN = WriteLine(4, $MSG)
$RTN = Close(4)
$MSG = CStr(Rnd(5)) + ": some status message@CRLF"
$RTN = Open(4, "C:\Temp\File2", 5)
$RTN = WriteLine(4, $MSG)
$RTN = Close(4)
$MSG = CStr(Rnd(5)) + ": some status message@CRLF"
$RTN = Open(4, "C:\Temp\File3", 5)
$RTN = WriteLine(4, $MSG)
$RTN = Close(4)
; display some sort of status that we're working..
$STAT[$CNT] + Chr(13)
$CNT = $CNT + 1
If $CNT = 3 $CNT = 0 EndIf
Sleep 0.5
Loop
code:
; z.kix - open 3 monitor windows
; Must monitor three files (file1, file2, and file3) which have status codes 1-5
; Files are written to constantly - must display all status "3" events
; Use Kix to start 3 monitor windows using "tail -f | grep 3" from Posix tools
"Starting" ?
; start the log file simulator
Shell "start kix32 c:\temp\x.kix"
; open separate windows to monitor 3 files
$FILES = "file1","file2","file3"
For Each $FILE in $FILES
$CMD = "start tail -f C:\Temp\" + $FILE + " | grep 3"
? "Monitoring $FILE"
Shell $CMD
Next