[Tutor] tail -f

dman dman@dman.ddts.net
Tue, 26 Mar 2002 16:09:19 -0600


I need to make a portion of a certain operate like 'tail -f'[1].  When
fully deployed, program will be reading from the serial port and
storing the data in a SQL database.  For initial testing deployment I
want it to read from a log file.  The log file is currently created as
a side effect of running kermit on the port.  I skimmed through the
source for tail, but nothing unusual jumped out at me and said "this
is how it does that!".  I tried to simply continue reading from the
file, but that only chewed up the CPU and didn't yield any output when
I echoed new data into the file.

Does anyone here know how to follow a file efficiently and correctly?


<slaps forehead>
Duh!  I just realized that I can open a pipe to 'tail -f'!  (as long
as it doesn't ever yield EOF)  I'd still like to know how it's done.

TIA,
-D

[1]  For the non-Unix folks out there, the "tail" command reads the
     last N lines of a file and writes them on stdout.  The '-f' flag
     (follow) means to continue to follow EOF as other programs append
     more data to the file.  One use is for watching log files.

-- 

Folly delights a man who lacks judgement,
but a man of understanding keeps a straight course.
        Proverbs 15:21