Page Hit Counter Vandalism & Writing FTP Results

Peter F. Ferris python at gbronline.com
Wed May 15 15:44:00 EDT 2002


Hi All,

Me again!

I'm having a bit of a struggle trying to write the contents of one file in
another, via FTP.

Here's the deal:  Someone (I know who, but...) is constantly "diddling" with
the page count for a departmental web page I've done. He likes to change the
counts to something fairly astronomical like, "932305709023" hits or
somesuch...  The count itself is stored in a simple text file called
"default.asp.cnt" on the server.  It's easy for him, with admin rights
<sigh!> to diddle the file.

So, I figured if I FTP'd the file, looked at it, if the change was out of
bounds  (say more than 100 hits since the last check) within a certain time
(say 5 minutes), I'll say it was tampered with. I would re-write it with the
previous value, and repeat processing.

This is my first time using the FTP library & it's objects.

The Crux of The Matter:

I want countff ("count from file") to be the # of hits, as stored in
"default.asp.cnt".

I have the following lines of code (among others!  But I feel the offending
code may be here...):

    	countff = str((ftp.retrlines('retr default.asp.cnt')))
	ftp.retrlines('retr default.asp.cnt')
    	print "countff var is: ", countff

When this runs, countff - which I WANT to contain a # from my page hit count
file - is actually "226 Transfer complete."!! So I'm snagging the result
rather than the file contents itself.  What am I doing incorrectly, and how
do I fix it?

I realize that both lines:
countff = str((ftp.retrlines('retr default.asp.cnt')))
ftp.retrlines('retr default.asp.cnt')
Do essentially the same thing.  However, I can't write THAT value to a file.
Both lines display a the total # of hits to the page, as stored in the
"default.asp.cnt" on the server.

All help TRULY appreciated,

--Pete

python AT wcom DOT com







More information about the Python-list mailing list