Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Re: Re: Tk tail -f - How?

by BrowserUk (Pope)
on Oct 09, 2003 at 21:42 UTC ( #298116=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Tk tail -f - How?
in thread Tk tail -f - How?

Oh! Sooo, you want your one-liner to have error recovery too:)

I had a devil of a job trying to simulate this without a network. Eventually, I tailed (slowly) a file on a my CD drive and the opened the tray.

Originally I had thought that using seek F, 0, 1 or die... to try and 'move' the file pointer without moving it would work but the OS noticed that the CD wasn't there and popped up a nice freindly dialogue suggesting I put it back! It might work on a network drive, it might not.

What I came up with was using -e to check that the file is still there, which seems to work fine with my CD drive. The error is reported by perl even before the CD has stopped spinning. You'll have to tell me if this works when a networked drive becomes disconnected.

perl -e"open F, '<', $ARGV[0] or die $!; while(1){ print <F>; -e $ARGV +[0] or die 'The file went away'; Win32::Sleep 100 }" file

It's got a bit long for a one-liner now, but it could probably be golfed :) I keep thinking it might be possible to use <code>perl -pe"..." and defeat the eof detection, but I haven't figured out how yet.

Any takers?


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://298116]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2020-11-27 03:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?