dbm write fails from cgi.

Using Perl on Rehat 6.1, I've made a dbm file template which I can work with through the standard dbmopen command.  If I use the same functions through CGI, however, I get an error "store returned -1, error number 13".

For Example

dbmopen(%template, "/path/template", 0666) || die;
print $template{"foo"}; #returns value in both cases
$template{"foo"} = "bar"; #fails if performed as a cgi script
dbmclose(%template);

Any ideas why this should happen?
BoBAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guadalupeCommented:
Not really sure but as soon as you talk abouit a difference between command line and browser there is the issue of permissions.  Remeber that when you run a perl script from the command line it inherits the permissions of the user running it but when you run it from a browser it takes the permission of a predefined user which is set in your server configuration. Try runnig this script from both the command line and your browser to see the difference in user.

#!/usr/local/bin/perl

print "Content-type: text/plain\n\n";

print "Effective User is: $>\n";

print "Real User is: $<\n";
0
ventolinCommented:
If this works from the command line and not from CGI, the user that the web server runs CGIs as doesn't have permission to open the file.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BoBAuthor Commented:
mode 0666 should give everyone rw access to the file.  That should easily cover the server user unless I need to allow execute access as well.
0
ventolinCommented:
example:
if your dbm file is owned by root and the permissions aren't set for others to read it, mode 0666 for dbm won't mean a thing-the cgi will not open the file.
0
BoBAuthor Commented:
You're right, I'm wrong.  Seems that's typical for beginner programmers. :)  Thanks guadalupe for your input.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Perl

From novice to tech pro — start learning today.