Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Got gdbm store returned -1 error 13 when trying to write!

by perlkid (Novice)
on Jun 27, 2002 at 07:38 UTC ( #177649=perlquestion: print w/replies, xml ) Need Help??

perlkid has asked for the wisdom of the Perl Monks concerning the following question:

Hi all respectful Perlmonks,

I keep getting the error as shown in the Apache error_log as
"gdbm store return -1 error 13" while I was trying to write
data into a db file using dbmopen.

dbmopen(%DB, "file", 666) ; $DB("moo") = "moo" ;

for this example I would get an error as
gdbm store return -1, errno 13, key "moo" at line blah blah..

It's a cgi program using perl, when I tested off line (just run from
the command line with parameters given)the data was written to the file.db
no problem.

However, when I ran this same program through a browser and trying
to add a record, it gave me an internal server error and the log
shown the error 13 as stated above. the permission for the file.db was
set to 777 just to make sure there was no problem with writing permission
the contents of the db can be view, but cann't write via a browser.

It's running on a Redhat, Perl 5.6.1, Apache 1.3.24 with mod_ssl

Anyone came accross the error above? I would appreciate any input you may have
thanks!!

regards,
-perlkid

Replies are listed 'Best First'.
Re: Got gdbm store returned -1 error 13 when trying to write!
by dws (Chancellor) on Jun 27, 2002 at 07:51 UTC
    Check the protection on your DBM file(s). The file protection needs to be expressed in octal, not decimal.   dbmopen(%DB, "file", 666) ; should be   dbmopen(%DB, "file", 0666);

    You might have been able to run this from the command line, but it'll create a file with funky protection bits. Since Apache is typicall run as a different user, they won't have access to the file.

      Thanks for the reply that was a good catch on my post, with

      dbmopen(%DB,"file",0666)

      that still giving me the error :(

      -perlkid
Re: Got gdbm store returned -1 error 13 when trying to write!
by Aristotle (Chancellor) on Jun 27, 2002 at 11:34 UTC
    I don't have anything to add to the given answer, but note that dbmopen is deprecated. use AnyDBM_File; and tie instead.

    Makeshifts last the longest.

      I finally found the problem, it was the permission problem.
      I originally thought that when I create a db using

      dbmopen(%DB, 'file', 0666)

      it would create a database file with the permission specified (0666) if the file doesn't exist
      and also I thought the db file would be "file.db" The real db file somehow (on the RedHat)
      has no extension and the permission was set to (0644 when investigating with the ls command)
      I still have no explanation to myself why though!
      but the problem is solved, thanks :)

      -perlkid
        Sounds like your umask is set to 0733. The extension is not necessarily appended for you - it depends on the DBM module you're using.

        Makeshifts last the longest.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://177649]
Approved by rob_au
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (1)
As of 2022-07-02 17:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (103 votes). Check out past polls.

    Notices?