public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Re: tail and win file handling
@ 2004-05-19 17:42 Paul Haas
  0 siblings, 0 replies; 5+ messages in thread
From: Paul Haas @ 2004-05-19 17:42 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tail and win file handling
  2004-05-18 17:23     ` C Wells
@ 2004-05-18 22:13       ` Larry Hall
  0 siblings, 0 replies; 5+ messages in thread
From: Larry Hall @ 2004-05-18 22:13 UTC (permalink / raw)
  To: C Wells, Cygwin List

At 01:08 PM 5/18/2004, you wrote:
>I can't change the application unfortunately, if I
>could I'd have it only log interesting stuff rather
>than the garbage it does.
>
>Is it worth trying maybe to link the file and tail the
>link ? or mess with a tee command ??


I guess I'm unclear on what you're doing and what's creating/removing
the file you're interested in and how it's being done.  The above ideas 
may work in your situation.  I don't know.  For the example you posted,
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.


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tail and win file handling
  2004-05-18 16:58   ` Larry Hall
@ 2004-05-18 17:23     ` C Wells
  2004-05-18 22:13       ` Larry Hall
  0 siblings, 1 reply; 5+ messages in thread
From: C Wells @ 2004-05-18 17:23 UTC (permalink / raw)
  To: Cygwin List

I can't change the application unfortunately, if I
could I'd have it only log interesting stuff rather
than the garbage it does.

Is it worth trying maybe to link the file and tail the
link ? or mess with a tee command ??

--- Larry Hall <cygwin-lh@cygwin.com> wrote:
> re tail and win file handles.

> Your going to have to use a different file name. 
> Windows doesn't 
> support the same semantics in this case.  The
> emulation Cygwin provides
> is as close as you're going to get (which ain't that
> close but... ;-) ).
> 


	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

--
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: tail and win file handling
  2004-05-18 13:36 ` tail and win file handling C Wells
@ 2004-05-18 16:58   ` Larry Hall
  2004-05-18 17:23     ` C Wells
  0 siblings, 1 reply; 5+ messages in thread
From: Larry Hall @ 2004-05-18 16:58 UTC (permalink / raw)
  To: C Wells, cygwin

At 09:31 AM 5/18/2004, you wrote:
>I am sorry if this has been covered before, but I was
>wondering if there is work around (probably not ;-(
>
>In unix you can do the following
>tail -f /somefile
>in another session
>rm -f /somefile
>echo OK > /somefile
>
>of course the tail stops working, but the file is
>recreated
>
>On a cygwin box
>tail -f c:/somefile
>in another session
>rm -f c:/somefile
>echo OK > c:/somefile
>'Access is denied'
>
>So obviously the tail puts a lock on the file,
>preventing an application from creating a new one,
>which in my case breaks the application. Any thoughts
>about how work around this, given I need to tail the
>file ? 


Your going to have to use a different file name.  Windows doesn't 
support the same semantics in this case.  The emulation Cygwin provides
is as close as you're going to get (which ain't that close but... ;-) ).


--
Larry Hall                              http://www.rfk.com
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
838 Washington Street                   (508) 893-9889 - FAX
Holliston, MA 01746                     


--
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* tail and win file handling
  2004-05-18 13:31 binutils 20040312-1 : problem linking 16bit x86 code with ld Corinna Vinschen
@ 2004-05-18 13:36 ` C Wells
  2004-05-18 16:58   ` Larry Hall
  0 siblings, 1 reply; 5+ messages in thread
From: C Wells @ 2004-05-18 13:36 UTC (permalink / raw)
  To: cygwin

I am sorry if this has been covered before, but I was
wondering if there is work around (probably not ;-(

In unix you can do the following
tail -f /somefile
in another session
rm -f /somefile
echo OK > /somefile

of course the tail stops working, but the file is
recreated

On a cygwin box
tail -f c:/somefile
in another session
rm -f c:/somefile
echo OK > c:/somefile
'Access is denied'

So obviously the tail puts a lock on the file,
preventing an application from creating a new one,
which in my case breaks the application. Any thoughts
about how work around this, given I need to tail the
file ?

Thanks



	
		
__________________________________
Do you Yahoo!?
SBC Yahoo! - Internet access at a great low price.
http://promo.yahoo.com/sbc/

--
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2004-05-19 15:11 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-19 17:42 tail and win file handling Paul Haas
  -- strict thread matches above, loose matches on Subject: below --
2004-05-18 13:31 binutils 20040312-1 : problem linking 16bit x86 code with ld Corinna Vinschen
2004-05-18 13:36 ` tail and win file handling C Wells
2004-05-18 16:58   ` Larry Hall
2004-05-18 17:23     ` C Wells
2004-05-18 22:13       ` Larry Hall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).