[Tutor] WTF?!?
Kirk Bailey
idiot1 at netzero.net
Thu May 20 00:32:46 EDT 2004
Ok, we upgraded critter; bigger drives, new(er) mother board, more
memory, actually sprouted some hairs on his teenage chest. HOWEVER, we
also upgraded to current Python- and FreeBSD. Straightaway we had
heacdaches.
And we fixed them. Permissions are a little different. ALSO, my page
counters stopped working.
Here's the old script:
#!/usr/local/bin/python
#
#
f1=open("count",'r')
count=int(f1.readline())
f1.close()
count=count+1
result=str(count)
print result
f1=open("count",'w')
f1.write(result+"\r\n")
f1.close
the file count stores the page hit count; it is stored in the cgi-bin
with the program.
Ok, it stopped wortking. FIRST off we check permissions. ok, minor
quibbles, fix. Loog now says cannot find file 'count'. ok, we go in
and execute from comand line, it works perfect.
Hmmm, had something like this before. Turns out that when you run a
program via the web server, it is now defaulting to the root dir for
that domain name (criter holds several domains, each with it's own
seperate directory tree structure including a web cgi-bin).
ok, I noticed one site in the box was counting. THE FILE WAS IN THE
QRONG PLACE. It was in the root directory for that site. hmmm, put it
in the 'right' place, it stops working. 'Default dir' is indeed the
root for the website as defined by the domain table in the apache
configuration.
ok, here is the updated counter:
#!/usr/local/bin/python
#
#
f1=open("./cgi-bin/count",'r')
count=int(f1.readline())
f1.close()
count=count+1
result=str(count)
print result
f1=open("./cgi-bin/count",'w')
f1.write(result+"\r\n")
f1.close
And it works just peachy. Now, did this arise due to changes in
python, or in FreeBSD?
So this is the current working version:
--
Respectfully,
Kirk D Bailey, Pinellas county Florida USA
think http://www.tinylist.org/ - $FREE$ Liberating software
+-------+ http://www.pinellasintergroupsociety.org/ - NeoPagan
| BOX | http://www.listville.net/ - $FREE$ list hosting!
+-------+ http://www.howlermonkey.net/ - $FREE$ email Accounts
kniht http://www.sacredelectron.org/ - My personal site
More information about the Tutor
mailing list