'''
import os, sys, time
+import select
+import sys, tty, termios
+
from optparse import OptionParser
class mtail:
- subversion_id = "$Id$"
-
default_time_format = "%H:%M:%S"
def __init__ (self, args ):
usage = """usage: %prog [options] file-or-dir ...
example:
# %prog -e '*access*' /var/log"""
- parser=OptionParser(usage=usage,version=self.subversion_id)
+ parser=OptionParser(usage=usage)
# tail_period
parser.add_option("-p","--period", type="int", dest="tail_period", default=1,
help="Files check period in seconds")
self.args.append("/var/log/httpd/sfa_access_log")
if self.options.verbose:
- print 'Version:',self.subversion_id
print 'Options:',self.options
print 'Arguments:',self.args
sys.exit(1)
counter = 0
- while 1:
+ fdin = sys.stdin.fileno()
+ while True:
## hit the period ?
# dont do this twice at startup
if (counter !=0 and counter % self.options.rescan_period == 0):
time.sleep(1)
counter += 1
-
+ # react on some keys - rough but convenient
+ if os.isatty(fdin):
+ # read stdin
+ typed=[]
+ while select.select([sys.stdin,],[],[],0.0)[0]:
+ typed.append(sys.stdin.read(1))
+# print 'found chars',typed
+ for char in typed:
+ if char.lower() in ['l']: os.system("clear")
+ elif char.lower() in ['m']:
+ for i in range(3) : print 60 * '='
+ elif char.lower() in ['q']: sys.exit(0)
+ elif char.lower() in ['h']:
+ print """l: refresh page
+m: mark
+q: quit
+h: help"""
+
###
if __name__ == '__main__':
mtail (sys.argv[1:]).run()