writing a file on my web site

Satheesh Babu vsbabu at erols.com
Sun Dec 17 08:12:58 EST 2000


With FTP tools, you probably have write permissions. But
others might not have write permissions to that file. You'll
need that so that web server process has permissions to
write to it.

chmod 666 should do it. Security alert - change the mode
only to your roncount.txt

"ron" <ronjeffries at acm.org> wrote in message
news:1D793E572F1CCC75.4177A7CD821DE2C4.6A38056B7E83389E at lp.airnews.net...
> I was experimenting with python and discovered that although I can
> upload and execute scripts to my web site's cgi-bin directory, I don't
> seem to be able to open files for write.
>
> If I do this ...
>
> filename = '.\\roncount.txt'
>
> myfile = open (filename,'r')
> line = myfile.read()
> print "line = ",
> print line
> myfile.close()
>
> myfile = open (filename,'w')
> myfile.write('contents here\n')
> myfile.close()
>
> with basically any directory name ahead of the file name, I get a
> traceback ...
>
> ]
> line = 4300 Traceback (innermost last): File
> "D:\s-z\xprogramming\cgi-bin\pyscript.py", line 44, in ? myfile = open
> (filename,'w') IOError: [Errno 13] Permission denied:
> '.\\roncount.txt'
>
> (The file did in fact have '4300' in it when it was read, so that part
> sees the correct file and reads it.)
>
> I've tried using my FTP fool to set permissions on the file, but it
> appears to have read/write/execute already and the FTP tool can't
> change it.
>
> What am I missing?
>
> Thanks!
>
> Ron





More information about the Python-list mailing list