dbm problem

Morning all, I'm totally new to all this Perl malarkey, so I'm praying you
> guys can help me.

> I'm trying to run a bulletin board application written by someone else, however whenever it gets
> to
> a DBM statement it stops, no error messages, nothing. I've been told that
> "The problem seems to be that your perl interpreter cannot handle any DBM
> activity from within a CGI script." and that it's some sort of
> configuration issue.

> I'm running activestate Perl for win32 on NT4 IIS4

ntollfreeAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
b2piConnect With a Mentor Commented:
Assuming that 1.) they're not zero sized, and 2.) you can write to them, ... you're done!!!

Thus, the problem all along was

      dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444);

1.) Opening a db with 444 (read-only for everyone) makes no sense. Noone will be able to write to it, which is fine, save that it will have no data in it.

2.) one must escape directory separators with Win32 (Arghhh!! Should have seen that right off.

0
 
b2piCommented:
Let me guess.  The bulletin board application wasn't written for ActiveState Perl, but rather for generic perl.

I have a vague suspicion/rememberance that dbm is one of the things that ActiveState perl doesn't support...
0
 
ntollfreeAuthor Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
b2piCommented:
Up at the top of the script, it should have a bunch of lines that say something like

use ...


One of those lines has a 'db' in it.  What is it?
0
 
ntollfreeAuthor Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for
0
 
b2piCommented:
Misstype... that should be a DBM_File...

0
 
ntollfreeAuthor Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for
0
 
ntollfreeAuthor Commented:
Okay, these are the only lines that I've found that may be of help
$areas_db="$(db_dir)/areas";
$dates_db="$(db_dir)/dates";
$sched_db="$(db_dir)/schedule";

I can't find any use.... or any dbm_file

Neil
0
 
b2piCommented:

Are there any lines like

require ...

Wait a minute, you're running activestate, so you can't be running perl4.  Therefore, if your script is actually using any dbm stuff, there absolutely must be a command to include the module.  

Ummm, that ellipsis (...) was meant to mean "anything goes here". For instance, you might have:

use NDBM_File;


0
 
ntollfreeAuthor Commented:
Okay, running activestate Perl v5.007. There are definately no use... lines anywhere. But the guy who developed it says they are not required and that it runs fine on his NT4 box...

0
 
b2piCommented:
> I'm trying to run a bulletin board application written by someone else, however whenever it gets
    > to
    > a DBM statement it stops, no error messages, nothing. I've been told that
    > "The problem seems to be that your perl interpreter cannot handle any DBM


What are the DBM statements?  How big is the script?
0
 
ntollfreeAuthor Commented:
Okay, running activestate Perl v5.007. There are definately no use... lines anywhere. But the guy who developed it says they are not required and that it runs fine on his NT4 box...

0
 
ntollfreeAuthor Commented:
Okay, my man tells me that if we can get this bit of script running then we should be able to get the bbs software working.

and it can be viewed at http://www.essexcc.gov.uk/scripts/discuss/test.pl

neil

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

print "MIH1 <br>\n";

dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444);

print "MIH2 <br>\n";

$DB{'1'} = "Testing";

print "MIH3 <br>\n";

dbmclose(%DB);

print "MIH4 <br>\n";

exit(0);
0
 
b2piCommented:
try

dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";


Also, check your permissions on both the directory (\inetpub\scritps\discuss) and the file.
0
 
ntollfreeAuthor Commented:
permissions are set to Everyone-full control, and have modified the line to no avail
0
 
b2piCommented:
There's no output at all?

By the way, change your access mode to 0666 (you're trying to write to a database which is read only)

Also, just for further debugging, try :


open(STDERR, ">&STDOUT");
my($dbf) = "\inetpub\scripts\discuss\testdb";
if (-f $dbf) {
   print "File exists<BR>\n";
   print "File size is " . -s $dbf;
   print "<BR>\n";
}
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";
0
 
ntollfreeAuthor Commented:
no output at all I'm afraid, and with this amendment, still no output. Remember, I'm a novice at this, could there be something regarding the Perl configuration that I need to do ?
0
 
b2piCommented:
I get it at least printing out the MIH1  
I assume you're getting that?
0
 
ntollfreeAuthor Commented:
no output at all I'm afraid, and with this amendment, still no output. Remember, I'm a novice at this, could there be something regarding the Perl configuration that I need to do ?
0
 
ntollfreeAuthor Commented:
sorry, yeah, that's what I mean, nada after the dbm statement
0
 
b2piCommented:
But those debug lines I gave you should have gone in BEFORE the dbm statement....

0
 
ntollfreeAuthor Commented:
sorry, yeah, that's what I mean, nada after the dbm statement
0
 
ntollfreeAuthor Commented:
To confirm, this is what I got in my script now, and I'm still getting nothing after MIH1. Sorry I'm slow on this, but I first saw Perl about 48 hours to me.

Cheers

Neil

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

print "MIH1 <br>\n";

open(STDERR, ">&STDOUT");
my($dbf) = "\inetpub\scripts\discuss\testdb";
if (-f $dbf) {
   print "File exists<BR>\n";
   print "File size is " . -s $dbf;
   print "<BR>\n";
}
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";

print "MIH2 <br>\n";

$DB{'1'} = "Testing";

print "MIH3 <br>\n";

dbmclose(%DB);

print "MIH4 <br>\n";

exit(0);
0
 
b2piCommented:
OK, now we're getting there.

First, you only need one dbmopen (it was a typo on my part.

Second, replace

}
dbmopen...

with

} else {
   print "db file not found<BR>\n";
}
if (-w $dbf) {
   print "File is writeable";
} else {
   print "File is NOT writeable";
}
print "<BR>\n";
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";


0
 
ntollfreeAuthor Commented:
And the response is.....

MIH1
db file not found
File is NOT writeable

Neil


0
 
b2piCommented:
OK, now (This should actually do it!) remove the old code (everything between
open(STDERR, ">&STDOUT");

to

dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";

and use this instead...

my($dbf) = "\inetpub\scripts\discuss\testdb";
open(FH, ">\inetpub\scripts\discuss\testdb") || die "No Write Access to directory";
print FH "asdfqwer" || die "No write access to file (Huh?)";
close(FH);
unlink("\inetpub\scripts\discuss\testdb")

print "<BR>\n";
dbmopen(%DB, "$dbf", 0664) || die "dbmopen failed: $!";
print "Opened successfully\n<BR>\n";
if (-f $dbf) {
       print "File exists<BR>\n";
       print "File size is " . -s $dbf;
       print "<BR>\n";
} else {
      print "db file not found<BR>\n";
}
if (-w $dbf) {
     print "File is writeable";
} else {
    print "File is NOT writeable";
}
print "<BR>\n";

0
 
ntollfreeAuthor Commented:
And the response is.....

MIH1
db file not found
File is NOT writeable

Neil


0
 
ntollfreeAuthor Commented:
Oh boy you're so going to hate this. I'm back to just getting MIH1 again.....

The code being used

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

print "MIH1 <br>\n";

open(STDERR, ">&STDOUT");
my($dbf) = "\inetpub\scripts\discuss\testdb";
open(FH, ">\inetpub\scripts\discuss\testdb") || die "No Write Access to directory";
print FH "asdfqwer" || die "No write access to file (Huh?)";
close(FH);
unlink("\inetpub\scripts\discuss\testdb")

print "<BR>\n";
dbmopen(%DB, "$dbf", 0664) || die "dbmopen failed: $!";
print "Opened successfully\n<BR>\n";
if (-f $dbf) {
       print "File exists<BR>\n";
       print "File size is " . -s $dbf;
       print "<BR>\n";
} else {
      print "db file not found<BR>\n";
}
if (-w $dbf) {
     print "File is writeable";
} else {
    print "File is NOT writeable";
}
print "<BR>\n";
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";

print "MIH2 <br>\n";

$DB{'1'} = "Testing";

print "MIH3 <br>\n";

dbmclose(%DB);

print "MIH4 <br>\n";

exit(0);


0
 
b2piCommented:
Have you tried running this from the command line rather than the browser?
0
 
ntollfreeAuthor Commented:
Oh boy you're so going to hate this. I'm back to just getting MIH1 again.....

The code being used

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

print "MIH1 <br>\n";

open(STDERR, ">&STDOUT");
my($dbf) = "\inetpub\scripts\discuss\testdb";
open(FH, ">\inetpub\scripts\discuss\testdb") || die "No Write Access to directory";
print FH "asdfqwer" || die "No write access to file (Huh?)";
close(FH);
unlink("\inetpub\scripts\discuss\testdb")

print "<BR>\n";
dbmopen(%DB, "$dbf", 0664) || die "dbmopen failed: $!";
print "Opened successfully\n<BR>\n";
if (-f $dbf) {
       print "File exists<BR>\n";
       print "File size is " . -s $dbf;
       print "<BR>\n";
} else {
      print "db file not found<BR>\n";
}
if (-w $dbf) {
     print "File is writeable";
} else {
    print "File is NOT writeable";
}
print "<BR>\n";
dbmopen(%DB, "\inetpub\scripts\discuss\testdb", 0444) || die "dbmopen failed: $!";

print "MIH2 <br>\n";

$DB{'1'} = "Testing";

print "MIH3 <br>\n";

dbmclose(%DB);

print "MIH4 <br>\n";

exit(0);


0
 
ntollfreeAuthor Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8
0
 
ntollfreeAuthor Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8
0
 
b2piCommented:
OK, can you arrange for write access (at least temporarily) to that directory for you as a user?
0
 
ntollfreeAuthor Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8
0
 
ntollfreeAuthor Commented:
tried that, still the same response
0
 
b2piCommented:
Add the full debug info (note the two "($!)"'s

open(FH, ">\inetpub\scripts\discuss\testdb") || die "No Write Access to directory ($!)";
print FH "asdfqwer" || die "No write access to file (Huh?) ($!)";
close(FH);
0
 
ntollfreeAuthor Commented:
tried that, still the same response
0
 
ntollfreeAuthor Commented:
result is...

No write access to directory <invalid arguement> C:\inetpub\scripts\discuss\testdb at line 8
0
 
ozoCommented:
open(FH, ">\inetpub\scripts\discuss\testdb")
should be
open(FH, '>\inetpub\scripts\discuss\testdb')
0
 
b2piCommented:
I'm about to give up here, these comments don't make sense.. try this.

Bloody hell....

Everywhere it says \inetpub\scripts\discuss\testdb, make it $dbf

change the assignment to $dbf to

$dbf = "C:\\inetpub\\scripts\\discuss\\testdb";


0
 
ntollfreeAuthor Commented:
From ozo's comment, I now get this error

MHI1<br>
<BR>

dbmopen failed : No such line or directory at C:\Inetpub\scripts\discuss\test.pl at line 14

and from b2pi
MIH1<br>
<BR>
Opened Successfully
<BR>
dbfile not found<BR>
MIH2<br>
MIH3<br>
MIH4<br>

Does this mean that we are there ?
0
 
b2piCommented:
After the program has executed, what files are in c:\inetpub\scripts\discuss\ ?
Most specifically, I'm looking for testdb*.*

0
 
ntollfreeAuthor Commented:
we got testdb.dir and .pag

Neil
0
 
ntollfreeAuthor Commented:
we got testdb.dir and .pag

Neil
0
 
ntollfreeAuthor Commented:
Okay, we're done. The chap who wrote this still has a few issues, but they're for another question.

Thank you very much for all your help, above and beyond the call of duty

Neil
0
All Courses

From novice to tech pro — start learning today.