<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Have you considered log4perl?<BR> <BR>Alex<BR><br> <BR><div><div id="SkyDrivePlaceholder"></div><hr id="stopSpelling">From: fulko.hew@gmail.com<br>Date: Fri, 4 May 2012 13:45:12 -0400<br>To: toronto-pm@pm.org<br>Subject: [tpm] more problems than solutions this week<br><br><font face="courier new,monospace">Here's the next problem...<br><br>How can you tell if a file pointer has been rewound?<br><br>The task:<br><br>...Follow the contents of a file (and process any new data)<br><br>The problem:<br>

<br>While testing the various permutations of how a file (log files)<br>can get updated you have typical actions like:<br> - append new data onto the end    (new stuff)<br> - delete the file and start over  (after log file rotation)<br>

<br>So one of my test modes was to use shell redirection to<br>write to a file.  ie. echo "stuff" > file<br><br>What I thought/expected would happen is that shell would create<br>a new copy of the file and write the string into it.<br>

[So when my app detects that the inode changed, it would<br>start reading the new file from the beginning.]<br><br>But what I've found is that the inode doesn't change!<br>[so I'd assume that the ">" redirection simply rewinds<br>

the write pointer to offset zero and writes the string<br>and then truncates the file at that point.]<br><br>So how can I detect that?<br><br>One solution I considered was: to remember what the size of<br>the file was (the last time I looked) and if the new size<br>

is smaller... it must have been truncated using this<br>technique.  That might work for the majority of occurrances,<br>but it doesn't work with the simplest test.<br><br>echo `date` > file     results in a 28 octet long file so I'll<br>

                       remember that it was 28 bytes long for later<br>...<br>echo `date` > file     the inode hasn't changed and neither has<br>                       the file size, yet there was 'new stuff<br>

                       that needs processing, that I won't see.<br>...<br><br>Suggestions?<br>(Or do I just throw up my hands in disgust and say I can't/don't<br>handle that condition?)<br><br><br>Fulko<br><br>

</font>
<br>_______________________________________________
toronto-pm mailing list
toronto-pm@pm.org
http://mail.pm.org/mailman/listinfo/toronto-pm</div>                                        </div></body>
</html>