perry.tew at cibavision.novartis.com
perry.tew at cibavision.novartis.com
Wed Oct 1 16:03:20 EST 2003
For security reasons, it's common to run the apache instance under a restricted user. Many times this is 'noboby'. I only assumed 'nobody' based on past problems by other people. At any rate, it seems you've solved your problem. -Perry hi Perry, Yes ! Thank you. I assumed if the relative paths were ok in a command line execution they must be ok in mod python. By the way, how do you figure the apache instance is running under 'nobody' ? In the httpd.conf there is clearly a section where the user and group are defined by default as 'apache'. On Tue, 30 Sep 2003 perry.tew at cibavision.novartis.com wrote: > Hello. > Is your apache instance running under the 'nobody' user, or something > similar? If so, chmoding the somefile.txt to 'apache' will not help. > I would advise caution in writing out files to relative paths. Given that > mod_python is an extension of Apache, would not a relative file > such as 'somefile.txt' be written to the ServerRoot or bin directory? > (I've never tried it). > Here's something to try: change the file from 'somefile.txt' to > '/tmp/somefile.txt'. Almost every user id can write to the /tmp directory. > > > Hope this helps, > Perry Tew > > > > > > <tpc at csua.berkeley.edu> > Sent by: mod_python-bounces at modpython.org > 09/30/2003 04:37 PM > > > To: <mod_python at modpython.org> > cc: > Subject: [mod_python] writing to a file from mod_python > > > > hello all I have the following script that ran fine from the command line: > > <code> > #!/usr/bin/env python > > #string1 = "hello world!" > > def writeFile(string1): > open('somefile.txt', 'w').write(string1) > > ## writeFile(string1) > </code> > > but as soon as I ported it to mod python I got the following: > > <paste> > Mod_python error: "PythonHandler mod_python.publisher" > > Traceback (most recent call last): > > File "/usr/lib/python2.2/site-packages/mod_python/apache.py", line 335, > in HandlerDispatch > result = object(req) > > File "/usr/lib/python2.2/site-packages/mod_python/publisher.py", line > 194, in handler > result = apply(object, (), args) > > File "/var/www/html/python/testing.py", line 7, in writeFile > > IOError: [Errno 13] Permission denied: 'somefile.txt' > </paste> > > I searched the web for the error message, chmod'ed 777 somefile.txt, and > even chown'ed and chgrp'ed to user and group apache, all to no avail. Is > there a way to write to a file from mod python ? > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python > > > > |