Re: Tailing a log file?

2007-06-22 Thread Paul Rubin
"Evan Klitzke" <[EMAIL PROTECTED]> writes: > I checked the source code for tail and they actually poll the file by > using fstat and sleep to check for changes in the file size. This > didn't seem right so I thought about it more and realized I ought to > be using inotify. So I guess I answered my

Re: Tailing a log file?

2007-06-22 Thread [EMAIL PROTECTED]
On Jun 22, 2:50 pm, "Kenji Noguchi" <[EMAIL PROTECTED]> wrote: > something like this? unix tail command does more fancy stuff > like it waits for timeout, and check if the file is truncated > or depending on incoming data it sleeps seconds , etc etc. > > #!/usr/bin/env python > import sys, select >

Re: Tailing a log file?

2007-06-22 Thread Falcolas
On Jun 22, 12:50 pm, "Kenji Noguchi" <[EMAIL PROTECTED]> wrote: > > I checked the source code for tail and they actually poll the file by > > using fstat and sleep to check for changes in the file size. This > > didn't seem right so I thought about it more and realized I ought to > > be using inoti

Re: Tailing a log file?

2007-06-22 Thread Stephen R Laniel
On Fri, Jun 22, 2007 at 11:46:56AM -0700, Evan Klitzke wrote: > I checked the source code for tail and they actually poll the file by > using fstat and sleep to check for changes in the file size. This > didn't seem right so I thought about it more and realized I ought to > be using inotify. So I g

Re: Tailing a log file?

2007-06-22 Thread Kenji Noguchi
something like this? unix tail command does more fancy stuff like it waits for timeout, and check if the file is truncated or depending on incoming data it sleeps seconds , etc etc. #!/usr/bin/env python import sys, select while True: ins, outs, errs = select.select([sys.stdin],[],[]) for

Re: Tailing a log file?

2007-06-22 Thread Evan Klitzke
On 6/22/07, Evan Klitzke <[EMAIL PROTECTED]> wrote: > Everyone, > > I'm interested in writing a python program that reads from a log file > and then executes actions based on the lines. I effectively want to > write a loop that does something like this: > > while True: > log_line = log_file.rea

Tailing a log file?

2007-06-22 Thread Evan Klitzke
Everyone, I'm interested in writing a python program that reads from a log file and then executes actions based on the lines. I effectively want to write a loop that does something like this: while True: log_line = log_file.readline() do_something(log_line) Where the readline() method bl