The following program have the same function as the linux's command:tail -f
logfile.log
But it print a lot of blank lines while showing on the stdout.
How to fix this problem and let it go ahead always
showing the end line as the log file's increasing.
#tail.py:
import os
import sys
class Tail:
def __init__(self,inputstream):
self.inputstream=inputstream
def tail(self):
self.inputstream.seek(0,2) #??Maybe this is where I'll need
fixed,But I don't know how to....
line=self.inputstream.readline().strip()
print line
if __name__=="__main__":
if len(sys.argv)<=1:
print "You must type a log file name"
sys.exit()
arg=file(sys.argv[1],'r+')
while(arg):
try:
t=Tail(arg)
t.tail()
except KeyboardInterrupt:
arg.close()
print "File closed"
--
http://mail.python.org/mailman/listinfo/python-list