473,587 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1267
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
1413
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. And preferably a different colour." -- John Latter, on Python's install instructions " What's more, these are three of Python's greatest...
0
1316
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 if-then-else expression. "This is the nature of Usenet and threaded discussions, where one person makes several comments, some less on-topic that the...
14
2842
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" in the subject of any post to this newsgroup. Please ignore the old thread. I've also updated my webpage http://ece.arizona.edu/~edatools/Python...
114
9767
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
6346
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 using a non open source tracker (called JIRA - never heard before of course) for Python itself. Does this smell "Bitkeeper fiasco" to anyone...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1454
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.