dbm write fails from cgi.

Posted on 2000-01-25
Medium Priority
Last Modified: 2010-03-05
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

Any ideas why this should happen?
Question by:BoB
  • 2
  • 2

Expert Comment

ID: 2386132
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.


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

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

print "Real User is: $<\n";

Accepted Solution

ventolin earned 200 total points
ID: 2386184
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.

Author Comment

ID: 2386240
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.

Expert Comment

ID: 2386814
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.

Author Comment

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

Featured Post

2018 Annual Membership Survey

Here at Experts Exchange, we strive to give members the best experience. Help us improve the site by taking this survey today! (Bonus: Be entered to win a great tech prize for participating!)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question