diff --git a/wwho.py b/wwho.py index 9422a43c..9a4e0e5b 100755 --- a/wwho.py +++ b/wwho.py @@ -1,10 +1,10 @@ #! /usr/bin/env python -# when-who, Sam K (2000) - import os,string,getopt,time,sys,struct """ usage : wwho [date] [-b secs (backwards)] [-p precision (sec/m/h/d)] [-l (last)] [-a (all last msgs)] [-f wtmp_file] [-d (debug)] DATE (2000 May 22 06:12:08) + + wfile : idem, except : [-a (access)] FILE """ optlist, args = getopt.getopt(sys.argv[1:], "adlb:p:f:") @@ -26,12 +26,21 @@ for i in optlist : if i[0] =='-p' : precision=float(i[1]) if i[0] =='-f' : utmpF=i[1] if debug : print "Option found : "+repr(i) + +if debug : print " argv[0] : %s" % sys.argv[0] + if not datesec : if date : - t=time.strptime(date,"%Y %b %d %H:%M:%S") - #we still have to guess the DaylightSsavingTime flag -> -1 - t2=[ t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],-1] - datesec = time.mktime(t2) + if string.lower(os.path.basename(sys.argv[0]))=="wfile.py" : + datesec=os.path.getmtime(date) #modif time + if all_last : datesec=os.path.getatime(date) #access time + print " Chosen file Time : %s" \ + %time.ctime(datesec) + else : + t=time.strptime(date,"%Y %b %d %H:%M:%S") + #we still have to guess the DaylightSsavingTime flag -> -1 + t2=[ t[0],t[1],t[2],t[3],t[4],t[5],t[6],t[7],-1] + datesec = time.mktime(t2) else : datesec =time.time() def unpackstr(s, i=0):