Link to home
Start Free TrialLog in
Avatar of BoB
BoB

asked on

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?
Avatar of guadalupe
guadalupe

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";
ASKER CERTIFIED SOLUTION
Avatar of ventolin
ventolin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BoB

ASKER

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.
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.
Avatar of BoB

ASKER

You're right, I'm wrong.  Seems that's typical for beginner programmers. :)  Thanks guadalupe for your input.