On 21/04/2006 11:24 AM, Ryan Ginstrom wrote: >> 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).
This possibly could be done without using the Windows API, just by using the mmap module and otherwise standard Python file functionality. However if the need would be met by a tail.exe, consider not re-inventing the wheel: http://en.wikipedia.org/wiki/GnuWin32 -- http://mail.python.org/mailman/listinfo/python-list