osdir.com
mailing list archive
Mozy Online Backup: 2GB Free. Automatic. Secure.

Subject: Re: Confused - msg#00318

List: apache.mod-perl

Date: Prev Next Index Thread: Prev Next Index
On Sun, Sep 22, 2002 at 10:33:36AM -0400, Rich DeSimone wrote:
> 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 "<title>Testing</title>";
> print "<h1>Teams list</h1><br>";
>
> my $dbh = DBI->connect("dbi:mysql:hello:localhost:3306", "root", "xxxx");
> my $sth1 = $dbh->prepare("select * from team1");
>
> $sth1->execute();
> while(my $team = $sth1->fetchrow_array()){
> print "$team<br>\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

It sounds like you have two different versions of perl on your machine. One
in /usr/bin and the other in /usr/local/bin. Try comparing:

/usr/bin/perl -V
and
/usr/local/bin/perl -V

>From there you can decide to get rid of the older perl if you want.

-josef





Was this page helpful?
Yes No
Thread at a glance:

Previous Message by Date: click to view message preview

Re: top for apache? [OT]

--On Sunday, September 22, 2002 09:54:02 -0400 Perrin Harkins <perrin@xxxxxxxx> wrote: Nigel Hamilton wrote: It would be great to have a similar tool for mod_perl/apache. The closest thing available is a combination of mod_status and Apache::Status. If you haven't tried these yet, give them a shot. They provide a good deal of information. You might also want to check out Apache::VMonitor. From the module's description: "This module emulates the reporting functionalities of top(1), extended for mod_perl processes, mount(1), and df(1) utilities. It has a visual alerting capabilities and configurable automatic refresh mode. All the sections can be shown/hidden dynamically through the web interface." -- Eric Cholet

Next Message by Date: click to view message preview

Re: BUG: Apache::Cookie v1.0

On Monday, 2002-09-23 at 11:11:02 -0400, darren chamberlain wrote: > * Michael McLagan <mmclagan@xxxxxxxxxxxx> [2002-09-21 11:45]: > > There is a bug in Apache::Cookie. It doesn't handle a cookie with > > zero bytes in it! > This is because Apache::Cookie is implemented in C, and C uses NULL as > the end of string terminator. No quite accurate. C has no concept of a string. There are a number of library functions for string handling that use '\0' as the string terminator. If somebody rewrites Apache::Cookie to replace those functions, it will be able to handle such cookies. > This is probably something that needs to be done in Perl, since I doubt > there's a way to check for "embedded" NULLs in a string in C... /* We assume there will always a '\0' to be found. */ char * find_nul(char *str) { while (*str) { str++; } return str; } What interests me much more is *why* a cookie should be able to contain *any* control character. If you want binary data in a cookie, you should encode it somehow. If the '\0' was a '\n', things would be much more interesting ... Lupe Christoph -- | lupe@xxxxxxxxxxxxxxxxx | http://www.lupe-christoph.de/ | | Big Misunderstandings #6398: The Titanic was not supposed to be | | unsinkable. The designer had a speech impediment. He said: "I have | | thith great unthinkable conthept ..." |

Previous Message by Thread: click to view message preview

Confused

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 "<title>Testing</title>";print "<h1>Teams list</h1><br>";   my $dbh = DBI->connect("dbi:mysql:hello:localhost:3306", "root", "xxxx");my $sth1 = $dbh->prepare("select * from team1");   $sth1->execute();while(my $team = $sth1->fetchrow_array()){ print "$team<br>\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 puck123@xxxxxxxxx

Next Message by Thread: click to view message preview

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 | | <jms1@xxxxxxxx> 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-----
Sign up for updates to this mailing list. email:
Loading Comments...
Home | News | Patents | Sitemap | FAQ | advertise

Advertising by