We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

dbm problem

ntollfree
ntollfree asked
on
Medium Priority
337 Views
Last Modified: 2012-05-04
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

Comment
Watch Question

Commented:
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...

Author

Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for

Commented:
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?

Author

Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for

Commented:
Misstype... that should be a DBM_File...

Author

Commented:
I just checked the faq, and it does support DBM. However I think that it was generic perl that this was written for

Author

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

Commented:

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;


Author

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...

Commented:
> 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?

Author

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...

Author

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);

Commented:
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.

Author

Commented:
permissions are set to Everyone-full control, and have modified the line to no avail

Commented:
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: $!";

Author

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 ?

Commented:
I get it at least printing out the MIH1  
I assume you're getting that?

Author

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 ?

Author

Commented:
sorry, yeah, that's what I mean, nada after the dbm statement

Commented:
But those debug lines I gave you should have gone in BEFORE the dbm statement....

Author

Commented:
sorry, yeah, that's what I mean, nada after the dbm statement

Author

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);

Commented:
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: $!";


Author

Commented:
And the response is.....

MIH1
db file not found
File is NOT writeable

Neil


Commented:
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";

Author

Commented:
And the response is.....

MIH1
db file not found
File is NOT writeable

Neil


Author

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);


Commented:
Have you tried running this from the command line rather than the browser?

Author

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);


Author

Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8

Author

Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8

Commented:
OK, can you arrange for write access (at least temporarily) to that directory for you as a user?

Author

Commented:
okay, from the command prompt

No write access to directory C:\inetpub\scripts\discuss\testdb at line 8

Author

Commented:
tried that, still the same response

Commented:
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);

Author

Commented:
tried that, still the same response

Author

Commented:
result is...

No write access to directory <invalid arguement> C:\inetpub\scripts\discuss\testdb at line 8
ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
open(FH, ">\inetpub\scripts\discuss\testdb")
should be
open(FH, '>\inetpub\scripts\discuss\testdb')

Commented:
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";


Author

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 ?

Commented:
After the program has executed, what files are in c:\inetpub\scripts\discuss\ ?
Most specifically, I'm looking for testdb*.*

Author

Commented:
we got testdb.dir and .pag

Neil
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
we got testdb.dir and .pag

Neil

Author

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
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.