delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/05/19/11:12:13

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Date: Wed, 19 May 2004 11:11:04 -0400 (EDT)
From: Paul Haas <paulh AT hamjudo DOT com>
Reply-To: paulh AT hamjudo DOT com
To: cygwin AT cygwin DOT com
Subject: Re: tail and win file handling
Message-ID: <Pine.LNX.4.44.0405191052310.13862-100000@bacon.hamjudo.com>
MIME-Version: 1.0

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019