#!/opt/imh-python/bin/python import os import re ''' parser to comb through exim_mainlog and return relevant information on spamming ''' # Variables used by parser result='' #mainLogPath = '/var/log/exim_mainlog' mainLogPath = '/Users/gilbertstawny/Scripts/exim_parser/exim_mainlog' mailLogPath = '/var/log/maillog' user_pattern = '' addr_pattern = '' dom_pattern = '' gen_pattern = '' time_pattern = '' id_string = '^.*1g1Dnq-00HVgR-If.*$' # dict for values/fields to be parsed via regular expressions def parse(): with open(mainLogPath,'r') as log: lines = log.readlines() for line in lines: if re.match(id_string, line): print (line) parse()