Take a look at the Perl Cookbook, Ch. 8.5 -- Trailing a Growing File
Tom uses seek:
for (;;) {
    while (<FH>) { .... }
    sleep $SOMETIME;
    seek(FH, 0, 1);
}

or

for (;;) {
    for ($curpos = tell(LOGFILE); <LOGFILE>; $curpos = tell(LOGFILE)) {
        # process $_ here
    }
    sleep $naptime;
    seek(LOGFILE, $curpos, 0);  # seek to where we had been
}



"Morehouse, Ken" <[EMAIL PROTECTED]> on 11/15/2000 09:30:15 AM

To:   "Win32 Perl Admin ActiveState LS (E-mail)"
      <[EMAIL PROTECTED]>
cc:    (bcc: Joe Peden/Tivoli Systems)
Subject:  Tail for NT




Has anyone used the Win32 port of tail.exe successfully? I can use it to -f
a file without issue when the output goes to STDOUT. If I try to pipe the
output to another process, tail no longer sees additions to the file. I can
tail a file without -f to a pipe okay.

What I'd like to do is this. I have a daily log file from my RADIUS server
that can't be modified while in use. I am being asked to provide realtime
log info from this file. I'd like to watch the logfile and pipe each new
additional record to a perl script that takes the info and puts it in a SQL
database.

Any ideas? [Tail -f <file> | somescript.pl] would be the ideal solution,
but
obviously doesn't work correctly.

Ken Morehouse II, MCSE
Telergy
IT Operations
Sr NT Administrator
[EMAIL PROTECTED]
(315) 362-2180 (DID)
(315) 362-0203 (FAX)
http://www.telergy.net


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin


_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-admin

Reply via email to