tail a file (win)

Ryan Ginstrom ginstrom at tree.odn.ne.jp
Thu Apr 20 21:24:06 EDT 2006


> Behalf Of david brochu jr
> I wrote a script to monitor ping activity and output it to a 
> log file. I am using windows and want to have another script 
> constantly check the latest entry to see if Request timed out 
> is seen. Is there a way to "tail" a file much like I would in 
> Unix so I can just see the latest entry and move from there? 

The method I would use that is not RAM/CPU intensive would be to create a
memory-mapped file, take the size of the file, and increment your pointer to
file_length - tail_size.

The Windows API functions to look at are:
CreateFile
CreateFileMapping
MapViewOfFile

I'm sorry, but I'm not a ctypes guru so can't tell you how you would
accomplish this in python. (The C(++) code is fairly straightforward,
however).

---
Regards,
Ryan Ginstrom




More information about the Python-list mailing list