473,324 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Python CGI question/issue

I have a working python script that takes in content from a form,
cleans it up, adds html formatting and then places it into my
index.html page on my server. When I had index.html set up as :
-rw-rw-r-- 1 carlos wheel 3517 Aug 4 09:51 index.html
I could not write back to the file,
Traceback (most recent call last):
File "/usr/local/www/cgi-bin/bob.py", line 24, in ?
file=open("../data/index.html","w")
IOError: [Errno 13] Permission denied: '../data/index.html'
[Wed Aug 4 09:50:47 2004] [error] [client X.X.X.X] Premature end of
script headers: /usr/local/www/cgi-bin/bob.py

and I though well shoot okay I need to make index.html -rw-rw-rw-,
when then made me a little paranoid. Is there a more simpler way to
make it possible for me to write back to index.html?
Jul 18 '05 #1
1 1253
ca******@gmail.com (Carlos Andrade) writes:
I have a working python script that takes in content from a form,
cleans it up, adds html formatting and then places it into my
index.html page on my server. When I had index.html set up as :
-rw-rw-r-- 1 carlos wheel 3517 Aug 4 09:51 index.html
I could not write back to the file,
Traceback (most recent call last):
File "/usr/local/www/cgi-bin/bob.py", line 24, in ?
file=open("../data/index.html","w")
IOError: [Errno 13] Permission denied: '../data/index.html'
[Wed Aug 4 09:50:47 2004] [error] [client X.X.X.X] Premature end of
script headers: /usr/local/www/cgi-bin/bob.py

and I though well shoot okay I need to make index.html -rw-rw-rw-,
when then made me a little paranoid. Is there a more simpler way to
make it possible for me to write back to index.html?


The cgi is running as whatever the webserver is set for, probably
"nobody". So it doesn't matter that you personally own the file. The
cgi can only edit the file if "nobody" can do so.

Changing files on a website can be done many ways. They have little
to do with python per se, though they can be done with python.

1. For fairly simple tasks, why not rewrite the app as a batch job,
run it as you in a sandbox, and then copy the resulting html file
to the web-visible docs dir. That way you can control the
permissions in the copy process. If it is a remote site, and you
need ftp, consider ftpmirror.py and similar tools.

2. You have almost described a Content Mgmt System (CMS), and
something like zope plone might do what you want. Or for ad hoc
editing you consider a wiki (e.g., moinmoin).

3. webdav is the official mechanism for web editing. I haven't tried
it personally.

4. There is an apache module for changing user and group during a cgi.
It comes with all kinds of dire warnings.

5. If you can run your own webserver, it can be run as you, and thus
can control those files. Better would be to make a totally new
userid just for this task.

6. You could run your own web service, e.g., via Twisted. As with a
std webserver, it is better to have a separate userid for the task.
--
ha************@boeing.com
6-6M21 BCA CompArch Design Engineering
Phone: (425) 342-0007
Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Irmen de Jong | last post by:
QOTW: "To make the instructions even friendlier it would also help if 'but Whatever You Do DON'T UNZIP THE FREAKIN' THING - This Means YOU John Latter!' were in large, bold, and underlined type. ...
0
by: Raymond Hettinger | last post by:
QOTW: "Of course it's still an ugly idiom. But there's a distinction between ugly-but-works and ugly-and-wrong." -- Michael Chermside commenting on one of the standard ways to simulate an...
14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
114
by: Maurice LING | last post by:
This may be a dumb thing to ask, but besides the penalty for dynamic typing, is there any other real reasons that Python is slower than Java? maurice
158
by: Giovanni Bajo | last post by:
Hello, I just read this mail by Brett Cannon: http://mail.python.org/pipermail/python-dev/2006-October/069139.html where the "PSF infrastracture committee", after weeks of evaluation, recommends...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.