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