def getrecord(file,uid, preserve = False):
  """Returns [int(unix_time),string(device),string(host)] from the lastlog formated file object, set preserve = True to preserve your position within the file"""
  position = file.tell()
  recordsize = struct.calcsize('L32s256s')
  file.seek(recordsize*uid)
  data = file.read(recordsize)
  if preserve:
    file.seek(position)
  try:
    returnlist =  list(struct.unpack('L32s256s',data))
    returnlist[1] = returnlist[1].replace('\x00','')
    returnlist[2] = returnlist[2].replace('\x00','')
    return returnlist
  except:
    return False
Returns [int(unix_time),string(device),string(host)] from the lastlog formated file object, set preserve = True to preserve your position within the file
recipes/Python/496768_Last_Login_Record_Extraction/recipe-496768.py