CGI Webcounter not quite, please

J. W. McCall no at
Tue Aug 5 18:44:57 CEST 2003

Sorry again if this is OT; I'm not sure if this is a python problem or 
just a CGI problem, but I couldn't find a decent CGI NG.  Let me know if 
there's somewhere else I should be posting.

I got this webcounter to be called directly (I still can't get it to be 
called from an HTML file with #exec or #include or anything).

Now the problem is that the part of the script that updates the count 
file doesn't work.  It's like it doesn't even execute.

Here's the script; don't worry, it's short and simple (I'm a Python 


print "Content-Type: text/html\n\n"
print "\n\n"

import os
import string

print "<HTML>"
print "<BODY>"
filenames = os.listdir(os.curdir)

if "count.txt" in filenames:
    input = open('count.txt', 'r')
    i = string.atoi(
    i = 0
    print "File doesnt exist<BR>"

i = i + 1
print "This page has been accessed " + `i` + " times.<BR>"
print "</BODY>"
print "</HTML>"

#it doesn't seem to execute this at all
output = open('count.txt', 'w')

Do you see any obvious problems with this?  It works fine when I call it 
from the command line.

It's on my Freeshell shell account.  It's a NetBSD system, I believe.

Any advice, ideas?


J. W. McCall

More information about the Python-list mailing list