?
Solved

dbm write fails from cgi.

Posted on 2000-01-25
5
Medium Priority
?
255 Views
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
dbmclose(%template);

Any ideas why this should happen?
0
Comment
Question by:BoB
  • 2
  • 2
5 Comments
 
LVL 3

Expert Comment

by:guadalupe
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.

#!/usr/local/bin/perl

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

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

print "Real User is: $<\n";
0
 
LVL 2

Accepted Solution

by:
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.
0
 

Author Comment

by:BoB
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.
0
 
LVL 2

Expert Comment

by:ventolin
ID: 2386814
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
 

Author Comment

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

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