Some bits-o-code from some bits-o-dreck-o-mine:
and# Close the log file and save information for next log check. # Remember where (and when) we stopped reading for next time. $FTPTrkLastReadPos = tell(FTPLOG); $FTPTrkLastReadTime = time; close(FTPLOG);
Why do I check the filesize of the file before reading it? Because someone may have deleted, reduced or truncated the file since I last read it. In my case I am able to handle this gracefully because I can look at the timestamps in each log entry and see if I have processed them before.# Get current characteristics of the log file my ($filesize,$modified,$created) = (stat(_))[7,9,10]; $FTPTrkLastReadPos = 0 if( $filesize < $FTPTrkLastReadPos ); # Process any and all new entries seek FTPLOG, $FTPTrkLastReadPos, 0;
In reply to Re: Opening a file at a designated offset based on closing of the file
by shenme
in thread Opening a file at a designated offset based on closing of the file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |