I'm new to Python, so please bear with me, and apologies in advance if this topic has been covered :)
I'm in the process of writing a script to check a list of SMTP logs from a certain domain. I want to ignore any lines that contain other parts of the SMTP conversation such as DATA or RCPT etc...
Here is the script:
import os
files = os.listdir('t:\smtpsvc1')
path = "t:\smtpsvc1" # I have used this variable as os.path.join wouldn't accept the variable 'files'
for f in files:
fullpath = os.path.join(path,f)
print(fullpath)
searchfile = open(fullpath, "r")
for line in searchfile:
if ('FROM' and '@somedomain.local' in line):
print (line)
searchfile.close()
The script runs, prints the name of the first file then checks the lines and outputs data like this:
2016-09-28 09:31:50 192.168.106.28 APPSERVER SMTPSVC1 SMTPSERVER 192.168.106.124 0 DATA - + 250 0 139 612 47 SMTP - - - -
This seems to trigger the condition looking for @somedomain.local, but seems to be ignoring the FROM part of the if statement. What am I doing wrong? Cheers in advance