Next | Welcome to my ~/bin | 31 |
Here's the main loop
First there's a block to make sure that ftail is still looking at the right file
while (1) { my ($dev, $ino) = stat $file; if (defined $dev && "$dev,$ino" ne $devino) { while (read F, my($buf), 8192) { print $buf; } open F, "<", $file or die "Couldn't open file $file: $!; aborting"; $devino = "$dev,$ino"; seek F, 0, 2 if $END; $END=0; }
Then, once the right file has been opened, it's pretty much the same as tail:
while (read F, my($buf), 8192) { print $buf; } sleep 1; seek F, 0, 1; }
Next | Menu | Copyright © 2005 M. J. Dominus |