This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: tail and win file handling


Larry Hall wrote:

> the file deleted by "rm" isn't deleted really until it's closed, which
> won't happen until 'tail' ends.  This is the way Windows works.  There's
> not much to be done about it (at least not in Cygwin).  Believe me,
> we've tried.

Here is a really ugly kludge to deal with a really ugly file system.

I'm sure I read about this sort of kludge before, so the idea is certainly
not original.

-------Cut here------
#!/usr/bin/perl -w
# this acts sort of like tail -f, but doesn't keep the
# open.  It is designed for non-unix systems where open files
# can't be deleted.
# It mindlessly shows the last 512 bytes of the file on startup
# rather than the last 10 lines.
#
#  Paul Haas, May 19, 2004
my $file = shift;
open(TF,$file) || die "Reading $file $!";
seek(TF,-512,2);
@lines=<TF>;
my $curpos=tell(TF);
close(TF);
print @lines;
sleep 1;
while(-r $file ) {
  open(TF,$file) || die "Rereading $file $!";
  seek(TF,$curpos,0);
  @lines=<TF>;
  $curpos = tell(TF);
  print @lines;
  close(TF);
  sleep 1;
}


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]