reading ftp log file..
Andrew Replogle
replogle2 at cox.net
Sat Feb 2 20:57:26 EST 2002
I'm trying to write a python script that watches an ftp log file.
Based on someone logging in and successfully transmitting a file it will use
the smptlib to generate somewhat of a dynamic mail as an "upload
confirmation". But I'm so new to python and programming in general that
this is proving very difficult.
this is what I have so far..
-----------------------------------
import os
import sys
import smtplib
ServerPath = 'c:\\Program Files\\G6 FTP Server\\'
logExists = os.path.isfile(ServerPath + 'FTP.log')
line = "230"
#print logExists
log = open(ServerPath + 'FTP.log')
lines = log.read()
for line in lines:
print "someone logged in"
break
-------------------------------------
the "230" you see is the code the ftp server puts in the log if X user
successfully logs in.. I'm trying to search for that in the file and if it
exists then go on with what the account is & what file they transfered.
it always prints "someone logges in" even if I change 'line' to a bazillion
zeros..
please let me know where I'm going wrong or what I'm misunderstanding. any
examples along with explinations are greatly appreciated..
thanks.
Andrew
More information about the Python-list
mailing list