Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mod_perl Can't open filehandles

Status
Not open for further replies.

MrCBofBCinTX

Technical User
Dec 24, 2003
164
US
I'm learning mod_perl since I learned that this could make a lot of problems with chrooted apache go away easier.
All my scripts work fine under mod_cgi.
My attempts to get them to run with PerlRun are failing when I try to open a file.
Code:
open (OUTFILE, ">bwcform_$t") or die ("Cannot open file");

errorlog isn't helpful:
[Sat Sep 20 13:32:31 2008] [error] PerlRun: `Cannot open file at /var/ line 63.\n'

Any suggestions?
 
Please note - I am not very experienced at this but to write to a file, I would use
Code:
">filenname.ext"

using bwcform_$t could make Perl assume that the $t part of your filename is a var and cannot find a value for it, so throws an error.

Keith
 
It's probably a matter of permissions. Make sure that the user that runs the script has effective write permissions to the directory that you're trying to write the file to.

Also, add the error string to your die:
Code:
open (OUTFILE, ">bwcform_$t") or die "Can't write to file: $!";

If it says something like "Can't write to file: permission denied" then it's a permission error. You can verify by chmodding the directory to something unsecure like 0777, which would allow all users write access to the directory. If the script can write the file then, then it means that PerlRun is probably executing your script in the context of a user that doesn't have permission to write in that directory (similarly to how Apache runs as "apache" or "nobody" by default, and without suexec, all CGI scripts run as this user instead of the user that actually owns the CGI script, and the same permission errors arise because of it).

-------------
Cuvou.com | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Yes, it was a permissions problem.
I guess that mod_perl runs as the user that apache runs as
I thought that I had loosened up permissions about a week ago when I last worked on this, but i guess not.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top