Re: Confused

2002-09-23 Thread Rich DeSimone

I have no idea why but it works all of a sudden.  I didn't do one thing.
How strange is thatthanks for your help guys I did learn some stuff.

Rich

- Original Message -
From: John Simpson [EMAIL PROTECTED]
To: Rich DeSimone [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Sunday, September 22, 2002 11:38 PM
Subject: Re: Confused


-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

On Sunday 22 September 2002 10:33, Rich DeSimone wrote:
 [Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] Can't locate
 loadable object for module DBI in @INC (@INC contains:
 /usr/local/lib/perl5/5.8.0/i686-linux
 /usr/local/lib/perl5/5.8.0
 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux
 /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .)
 at /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243
 [Sat Sep 21 18:21:08 2002] [error] [client 10.0.0.2] BEGIN
 failed--compilation aborted at
 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243.

howdy,

usually can't locate loadable object means it's looking for some kind of
shared library (i.e. a .DLL or .so file) and either can't find it, or
can't open it (permissions issues.) for DBI it may be looking for a
shared library to access the specific database type you're using (such as
libmysql.so or something similar- i would include a real filename but
i'm at home and my dev boxes are at work behind the firewall.)

i would start by reading /usr/.../DBI.pm (where the error message is
happening), look at line 243, and see if you can figure out what library
it's trying to load. then figure out why it can't load, whether it's a
permissions issue or a missing symlink or something.

also remember that the built-in @INC for mod_perl may not the same as the
built-in @INC for your command-line perl interpreter. the list above is
the built-in @INC for the mod_perl you're running, and running perl -V
will show you the built-in @INC for your command-line perl.

if you've upgraded perl, DBI, or DBD::mysql since you compiled mod_perl,
it may be looking for old library files that don't exist anymore.

you may also want to try running your httpd with the -X parameter,
inside of a program like strace or ltrace, and read the output file to
see what library it's trying to load. it can generate a LOT of output,
but it will show you exactly what filename it's trying to open and what
the error code was (i.e. ENOENT=file not found, EPERM=permissions, etc.)

try something like this:

ltrace -S -o trace.out /usr/sbin/httpd -X

you won't see anything extra on the screen while it's running, and it will
run much more slowly than normal (you don't want to leave it running like
this all the time.)

try hitting your script from a browser. after it doesn't work, go back to
the console where this command is running and hit control-c to shut down
httpd. read through the trace.out file and see if you can find the
open() or dlopen() call that's failing. you may be able to use the time
stamp from your error_log to find the right place in the trace output
file.



some other things to try...

you may want to run ldconfig to rebuild your shared library cache and
see if that helps (it doesn't hurt anything to run it whenever you feel
like it.) start/restart your httpd after it finishes, and then try your
script again.



if it's a permissions issue (and even if it's not) i have a script that i
call pfix, which fixes permissions on the perl library directories.
some CPAN modules, when you install them as root, install the files with
root-only permissions. i run this script as a cron job every day, along
with every time i install anything from CPAN. the script looks like this:

#!/bin/sh
chmod -R go=u-w /usr/lib/perl* /usr/local/lib/perl* /www/perl



sorry i can't be more help than this, i haven't switched to perl 5.8,
apache 2, or mod_perl2 yet, which means i can't do a live test myself.

- --
- 
| John Simpson Programmer at Large |
| [EMAIL PROTECTED] http://www.jms1.net/ |
- 
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE9joyjEB9RczMG/PsRArJJAJ9RWpzHiE6uCWeDIS0JMfK2gMHm4gCgqqcW
2ueAGIytfnWhapbMcXwDteE=
=Skl2
-END PGP SIGNATURE-






Confused

2002-09-22 Thread Rich DeSimone





Hi I am just messing around with Perl DBI/Apache 
and I can't seem to understand this problem. Right now I am just trying to 
write a simple CGI perl script that just displays a mysql query. I am 
using this code...

#!/usr/bin/perl -w

use DBI;use CGI 
qw(fatalsToBrowser);

print CGI::header();print 
"titleTesting/title";print "h1Teams 
list/h1br";

my $dbh = 
DBI-connect("dbi:mysql:hello:localhost:3306", "root", "");my $sth1 = 
$dbh-prepare("select * from team1");

$sth1-execute();while(my $team = 
$sth1-fetchrow_array()){print "$teambr\n";}

$dbh-disconnect;

--
Now when I run the file from a shell it queries 
the database properly and everything prints out fine. The problem is when 
I put this file in cgi-bin and try to execute it via www I am getting an error 
and this is what the apache error_log is saying...

[Sat Sep 21 18:21:08 2002] [error] [client 
10.0.0.2] Premature end of script headers: football.pl[Sat Sep 21 18:21:08 
2002] [error] [client 10.0.0.2] Can't locate loadable object for module DBI in 
@INC (@INC contains: /usr/local/lib/perl5/5.8.0/i686-linux 
/usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i686-linux 
/usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl .) at 
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243[Sat Sep 21 
18:21:08 2002] [error] [client 10.0.0.2] BEGIN failed--compilation aborted at 
/usr/local/lib/perl5/site_perl/5.8.0/i686-linux/DBI.pm line 243.[Sat Sep 21 
18:21:08 2002] [error] [client 10.0.0.2] Compilation failed in require at 
/usr/local/apache2/cgi-bin/football.pl line 3.[Sat Sep 21 18:21:08 2002] 
[error] [client 10.0.0.2] BEGIN failed--compilation aborted at 
/usr/local/apache2/cgi-bin/football.pl line 3.

Regular perl scripts (non DBI) run fine so I 
don't know if there is something special didn't set up. I am running the 
latest stable apache2 and mod_perl. I installed Apache::DBI as well and 
the README says "For Apache::DBI you need to enable the appropriate call-back 
hooks when making mod_perl: perl Makefile.PL 
PERL_CHILD_INIT=1 PERL_STACKED_HANDLERS=1." I tried that but the latest 
mod_perl doesn't recognize those parameters. Maybe that could have 
something to do with it? 

I am sorry if this is 
an obvious answer (IE I didn't read the FAQs thoroughly enough) but I am new to 
this stuff and some of that info can be overwhelming at times. Also I hope 
this is the right mailing list because it seems to be a mod_perl related 
problem

Thanks,

Rich
[EMAIL PROTECTED]