Trouble writing to a file from mod_perl
I'm trying to write for a file from a mod_perl script. I can write successfully to a file located in /tmp, but I cannot write to the dir containing the script, nor to the apache logs dir. How can this be accomplished? Is there a setting in httpd.conf that I need to specify? Is it a file permissions problem? I don't want to make the script dir world read/writable. Would the Apache::Log interface allow me to write to my own file? My code looks something like the following: open(LOG, /usr/local/apache/htdocs/aws/perl/rod.log) || print script.pl: Can't write to log file.; print LOG hello\n; close LOG I'm running mod_perl 1.27 and Apache 1.3.27 on Mandrake Linux. Any help would be greatly appreciated. Rod Brick
Re: Trouble writing to a file from mod_perl
Rod Brick wrote: I'm trying to write for a file from a mod_perl script. I can write successfully to a file located in /tmp, but I cannot write to the dir containing the script, nor to the apache logs dir. How can this be accomplished? Is there a setting in httpd.conf that I need to specify? Is it a file permissions problem? I don't want to make the script dir world read/writable. Would the Apache::Log interface allow me to write to my own file? My code looks something like the following: open(LOG, /usr/local/apache/htdocs/aws/perl/rod.log) || print script.pl: Can't write to log file.; print LOG hello\n; close LOG change it to open(LOG, /usr/local/apache/htdocs/aws/perl/rod.log) || print script.pl: Can't write to log file : $! ; print LOG hello\n; close LOG And at least it'll tell yuo why it can't write to the file :) Carl
Re: Trouble writing to a file from mod_perl
Hello Rod Brick, Thursday, July 31, 2003, 3:01:57 PM, you wrote: RB I'm trying to write for a file from a mod_perl script. I can write RB successfully to a file located in /tmp, but I cannot write to RB the dir containing the script, nor to the apache logs dir. How can RB this be accomplished? Is there a setting in httpd.conf that I RB need to specify? Is it a file permissions problem? I don't want to RB make the script dir world read/writable. Would the Apache::Log RB interface allow me to write to my own file? My code looks something RB like the following: open(LOG, /usr/local/apache/htdocs/aws/perl/rod.log) || print RB script.pl: Can't write to log file.; RB print LOG hello\n; RB close LOG RB I'm running mod_perl 1.27 and Apache 1.3.27 on Mandrake Linux. Any RB help would be greatly appreciated. RB Rod Brick I'm pretty sure -- this is a permission problem. You could check $! to see the source of the problem and print it to STDERR instead of STDOUT which under mod_perl is tied to client socket (of couse if you want to see message in the error log). open(...) || print STDERR Some problem to open: $!\n; Depends of you apache/mod_perl setup it's quite possible that your apache processes run under user which has no privileges to write into /usr/local/apache/htdocs/aws/perl/rod.log. -- WBR, Mike P. Mikhailov mailto: [EMAIL PROTECTED] ICQ:280990142 Those who learn from history are doomed to have it repeated to them anyway.