You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by jm...@vipcompute.com on 2000/03/24 22:42:24 UTC

"use lib" statements in startup.pl

> You could also have put
> 
> use lib "/exports/www/script/lib/perl";
> 
> in the BEGIN block in startup.pl to put /exports/www/script/lib/perl
> into @INC.

I saw this, and added a "use lib" line to my startup.pl (the second 
one, below).  I am receiving an error, and the error does not include 
either of the "use lib" directories below in @INC.  Here is my 
startup.pl:

#!/usr/local/bin/perl

BEGIN {
        use Apache ();
        use lib Apache->server_root_relative('lib/perl');
        use lib "/usr/local/share/apache/cgi-bin/common";
}

use Apache::Registry ();
use Apache::Constants();
use CGI qw(-compile :all);
use CGI::Carp ();

# Other common modules

use LWP ();
require "cgi-jdm/hashdata.pl";

1;

Here is the error when I try to use my script.  The script has 
require "foolib.pl";
require "foolib2.pl";

at the top of it.  Both libraries exist in the "common" directory 
listed in the startup.pl script.

The error is:

Can't locate foolib.pl in @INC (@INC contains: 
/usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.00503 
/usr/local/lib/perl5/site_perl/5.005/aix 
/usr/local/lib/perl5/site_perl/5.005 .) at insert.pl line 3

As you can see, @INC does not contain either of the directories.  
AIX 4.3.3, Apache 1.3.11, mod_perl 1.21

Any help greatly appreciated.

-- Jonathan

Re: "use lib" statements in startup.pl

Posted by "G.W. Haywood" <ge...@jubileegroup.co.uk>.
Hi again,

On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:

> Well, I did not see the message in my error_log, but I DID see it at 
> the command line:

I thought about it a bit => more info.

When Apache isn't already running, it sends the output from startup.pl
etc. for STDERR to the terminal that is trying to start it.  That's
because the configuration files haven't been completely parsed at this
point and Apache doesn't know whether or not they're broken.  If it's
already running, it sends the output to the error_log instead because
it knows its current configuration is OK - but it doesn't know about
the (possibly new and exciting) configuration it's reading.  If you
think about it for long enough it makes sense.  You're just sending
different signals to httpd through apachectl, some of which (e.g.
`apachectl graceful') will not stop Apache, if it's already running.

Then I found it best to stop thinking about it, and do something else.

How are you getting on?

73,
Ged.


Re: "use lib" statements in startup.pl

Posted by jm...@vipcompute.com.
Back again.  As always, I appreciate the help.

I did some further debuigging.  In the startup.pl, I put in a loop that 
prints out all of the directories in @INC at the end of the BEGIN 
block.  Here is the output from that.

Running startup.pl
@INC contains:
/usr/local/share/apache/cgi-bin/common
/usr/local/share/apache/lib/perl
/usr/local/lib/perl5/5.00503/aix
/usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/aix
/usr/local/lib/perl5/site_perl/5.005
.
/usr/local/share/apache/
/usr/local/share/apache/lib/perl
apachectl start: httpd started

This looks fine (the top two are the directories I am trying to add to 
@INC, but when I try to run my script, I get the same error (look 
closely at @INC in this error - the two additional directories are not 
there!):

Can't locate foolib.pl in @INC (@INC contains: 
/usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.0
0503 /usr/local/lib/perl5/site_perl/5.005/aix 
/usr/local/lib/perl5/site_perl/5.005 .) at insert.pl line 3

> Same answer, more or less.  Find out what's in @INC after your
> "use lib" statements (e.g. more print statements in BEGIN blocks,
> stuff like that).

Did this.

>  Read the Guide about what happens to @INC under
> Apache/mod_perl.

About to do this.

> Have you got any more info?
> You haven't got another copy of httpd running as well, have you?

Nope - only one.

> Are you getting anything written in your error_logs now?

Yes - the above output from startup.pl, plus 

[notice] Apache/1.3.11 (Unix) mod_perl/1.21 configured -- resuming 
normal operations

> Have you checked the dates and times in the log entries to make sure
> that they were made when you think they were made?

They seem to be made when I thought they were.

Again, thanks for any help and direction.  I am off to see what I can 
find in the Guide.

-- Jonathan

Re: "use lib" statements in startup.pl

Posted by "G.W. Haywood" <ge...@jubileegroup.co.uk>.
Hi again,

On Sat, 25 Mar 2000, G.W. Haywood wrote:

> On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:
> 
>> Well, I did not see the message in my error_log, but I DID see it at 
>> the command line:
>> What does this mean?
> 
> It means that either
> 
> (1) the Apache parent didn't execute startup.pl, something else did
> or
> (2) you didn't do what I wanted you to do
> or
> (3) I don't have the faintest idea what's going on.
> 
> My guess is (1).

Nope, looks like it was (3) after all.
I just tried it on my server and it comes out on the terminal here too.
It seems your Apache is running startup.pl OK.

Er, **sorry** if I confused you with this screwup.

>> cd apachectl start: httpd started

I guess this was just a typo?

>> Where do I go next?
> More debugging.

Same answer, more or less.  Find out what's in @INC after your
"use lib" statements (e.g. more print statements in BEGIN blocks, 
stuff like that).  Read the Guide about what happens to @INC under
Apache/mod_perl.

Have you got any more info?
You haven't got another copy of httpd running as well, have you?
Are you getting anything written in your error_logs now?
Have you checked the dates and times in the log entries to make sure
that they were made when you think they were made?

73,
Ged.


Re: "use lib" statements in startup.pl

Posted by "G.W. Haywood" <ge...@jubileegroup.co.uk>.
Hi there,

On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:

> Well, I did not see the message in my error_log, but I DID see it at 
> the command line:
> 
>  /usr/local/share/apache/bin> # apachectl stop
> apachectl stop: httpd stopped
>  /usr/local/share/apache/bin> # apachectl start
> Running startup.pl
> cd apachectl start: httpd started
> 
> What does this mean?

It means that either

(1) the Apache parent didn't execute startup.pl, something else did
or
(2) you didn't do what I wanted you to do
or
(3) I don't have the faintest idea what's going on.

My guess is (1).

> Where do I go next?

More debugging.  Find out what's executing startup.pl and why it's not
httpd.  You *have* got a mod_perl server running?  What does `httpd
-l' say?  Find out what's in @INC after your "use lib" statements
(e.g. more print statements in BEGIN blocks, stuff like that).
Read the Guide about what happens to @INC under Apache/mod_perl.

> sorry to surprise you.

Like I said, the surprise would have been if it was in your error_log:)

I'm going to hit the sack now, it's gone midnight here.

73,
Ged.


Re: "use lib" statements in startup.pl

Posted by jm...@vipcompute.com.
Well, I did not see the message in my error_log, but I DID see it at 
the command line:

 /usr/local/share/apache/bin> # apachectl stop
apachectl stop: httpd stopped
 /usr/local/share/apache/bin> # apachectl start
Running startup.pl
cd apachectl start: httpd started

What does this mean?
Where do I go next?

Thanks for any help - sorry to surprise you.

-- Jonathan

On 24 Mar 00, at 22:02, G.W. Haywood wrote:

> Hi there,
> 
> On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:
> 
> > > use lib "/exports/www/script/lib/perl";
> > > 
> > > in the BEGIN block in startup.pl to put
> > > /exports/www/script/lib/perl into @INC.
> > 
> > I saw this, and added a "use lib" line to my startup.pl (the second
> > one, below).  I am receiving an error, and the error does not
> > include either of the "use lib" directories below in @INC.
> 
> Try putting a debug statement into the BEGIN block in your startup.pl:
> 
>    print STDERR "Running startup.pl\n";
> 
> If you see this message in your error_log it means your startup.pl is
> getting executed (and I'll be very surprised...:)
> 
> 73,
> Ged.
> 
> 
> > Here is my startup.pl:
> > 
> > #!/usr/local/bin/perl
> > 
> > BEGIN {
> >         use Apache ();
> >         use lib Apache->server_root_relative('lib/perl');
> >         use lib "/usr/local/share/apache/cgi-bin/common";
> > }
> > 
> > use Apache::Registry ();
> > use Apache::Constants();
> > use CGI qw(-compile :all);
> > use CGI::Carp ();
> > 
> > # Other common modules
> > 
> > use LWP ();
> > require "cgi-jdm/hashdata.pl";
> > 
> > 1;
> > 
> > Here is the error when I try to use my script.  The script has
> > require "foolib.pl"; require "foolib2.pl";
> > 
> > at the top of it.  Both libraries exist in the "common" directory
> > listed in the startup.pl script.
> > 
> > The error is:
> > 
> > Can't locate foolib.pl in @INC (@INC contains: 
> > /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.00503 
> > /usr/local/lib/perl5/site_perl/5.005/aix 
> > /usr/local/lib/perl5/site_perl/5.005 .) at insert.pl line 3
> > 
> > As you can see, @INC does not contain either of the directories. 
> > AIX 4.3.3, Apache 1.3.11, mod_perl 1.21
> > 
> > Any help greatly appreciated.
> > 
> > -- Jonathan
> > 
> 



Re: Why 'require' required?

Posted by Ken Williams <ke...@forum.swarthmore.edu>.
J.Gao@isu.usyd.edu.au (Jie Gao) wrote:
>PerlAuthenHandler my::AuthCookieHandler->authen
>PerlAuthzHandler my::AuthCookieHandler->authz

If you're using recent versions of Apache::AuthCookie, then you *are* going to
change ->authen and ->authz to ->authenticate and ->authorize, right? =)

The next version of AuthCookie, which I'm working on now, will have these
deprecated methods removed.


  -------------------                            -------------------
  Ken Williams                             Last Bastion of Euclidity
  ken@forum.swarthmore.edu                            The Math Forum



Why 'require' required?

Posted by Jie Gao <J....@isu.usyd.edu.au>.
Hi All,

I have this in my .htaccess file:

PerlSetupEnv On
PerlSetEnv SYBASE /usr/local/open_client
PerlSetEnv DBI_DRIVER Sybase
PerlAuthenHandler my::AuthCookieHandler->authen
PerlAuthzHandler my::AuthCookieHandler->authz
AuthType my_domain
AuthName Authen
PerlSetVar AuthenLoginPageLocation 'https://xxx.ucc.usyd.edu.au/perl-bin/login.cgi'
PerlSetVar DSName mydb
PerlSetVar DSF /usr/local/open_client/dbconf
PerlSetVar VirtualServerName xxx.ucc.usyd.edu.au
PerlSetVar TimeOut 50000
PerlSetVar CourseAllowed "pcol2001 pcol2002"
PerlSetVar EnrolCkDSName SYB_FLX_TRAIN
require valid-user
PerlSetVar AuthCookieDebug 6

Now if I comment out "require valid-user", neither of the
PerlAuthenHandler and PerlAuthzHandler will be evoked, even though it
is a phoney requirement for my handler; if I put in one require
statement, like 'require authentication', it'll start working again.

Anybody have any idea as to why?

Regards,


Jie


Re: "use lib" statements in startup.pl

Posted by jm...@vipcompute.com.
> > As you can see, @INC does not contain either of the directories. 
> > AIX 4.3.3, Apache 1.3.11, mod_perl 1.21
> 
> This may be a silly question, but are you executing your script under
> Apache::Registry or just as a regular cgi script?  Apache::Registry
> allows you to run (mostly) unmodified perl cgi scripts under mod_perl,
> but the scripts have to be executed from a location which has
> Apache::Registry as its PerlHandler.
> 
> For instance, in httpd.conf:
> 
> <Location /perl>
>         SetHandler      perl-script
>         PerlHandler     Apache::Registry
>         PerlSendHeader  On
>         Options         +ExecCGI
> </Location>
> 
> Then your script would go in <DocumentRoot>/perl.
> 
> - Matt

Not a silly question at all.  I was running it under Apache::PerlRun 
instead of Apache::Registry.  However, I made the change, 
stopped and started Apache, and tried again, and got the same 
@INC error.

-- Jonathan


Re: "use lib" statements in startup.pl

Posted by Matt Carothers <ma...@telepath.com>.

On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:

> > use lib "/exports/www/script/lib/perl";
> 
> I saw this, and added a "use lib" line to my startup.pl (the second 
> one, below).  I am receiving an error, and the error does not include 
> either of the "use lib" directories below in @INC.  Here is my 
> startup.pl:
...
> Here is the error when I try to use my script.  The script has 
> require "foolib.pl";
> require "foolib2.pl";
> 
> at the top of it.  Both libraries exist in the "common" directory 
> listed in the startup.pl script.
> 
> The error is:
> 
> Can't locate foolib.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.00503 
> /usr/local/lib/perl5/site_perl/5.005/aix 
> /usr/local/lib/perl5/site_perl/5.005 .) at insert.pl line 3
> 
> As you can see, @INC does not contain either of the directories.  
> AIX 4.3.3, Apache 1.3.11, mod_perl 1.21

This may be a silly question, but are you executing your script under
Apache::Registry or just as a regular cgi script?  Apache::Registry allows
you to run (mostly) unmodified perl cgi scripts under mod_perl, but the
scripts have to be executed from a location which has Apache::Registry as
its PerlHandler.

For instance, in httpd.conf:

<Location /perl>
        SetHandler      perl-script
        PerlHandler     Apache::Registry
        PerlSendHeader  On
        Options         +ExecCGI
</Location>

Then your script would go in <DocumentRoot>/perl.

- Matt


Re: "use lib" statements in startup.pl

Posted by "G.W. Haywood" <ge...@jubileegroup.co.uk>.
Hi there,

On Fri, 24 Mar 2000 jmeltze@vipcompute.com wrote:

> > use lib "/exports/www/script/lib/perl";
> > 
> > in the BEGIN block in startup.pl to put /exports/www/script/lib/perl
> > into @INC.
> 
> I saw this, and added a "use lib" line to my startup.pl (the second 
> one, below).  I am receiving an error, and the error does not include 
> either of the "use lib" directories below in @INC.

Try putting a debug statement into the BEGIN block in your startup.pl:

   print STDERR "Running startup.pl\n";

If you see this message in your error_log it means your startup.pl is
getting executed (and I'll be very surprised...:)

73,
Ged.


> Here is my startup.pl:
> 
> #!/usr/local/bin/perl
> 
> BEGIN {
>         use Apache ();
>         use lib Apache->server_root_relative('lib/perl');
>         use lib "/usr/local/share/apache/cgi-bin/common";
> }
> 
> use Apache::Registry ();
> use Apache::Constants();
> use CGI qw(-compile :all);
> use CGI::Carp ();
> 
> # Other common modules
> 
> use LWP ();
> require "cgi-jdm/hashdata.pl";
> 
> 1;
> 
> Here is the error when I try to use my script.  The script has 
> require "foolib.pl";
> require "foolib2.pl";
> 
> at the top of it.  Both libraries exist in the "common" directory 
> listed in the startup.pl script.
> 
> The error is:
> 
> Can't locate foolib.pl in @INC (@INC contains: 
> /usr/local/lib/perl5/5.00503/aix /usr/local/lib/perl5/5.00503 
> /usr/local/lib/perl5/site_perl/5.005/aix 
> /usr/local/lib/perl5/site_perl/5.005 .) at insert.pl line 3
> 
> As you can see, @INC does not contain either of the directories.  
> AIX 4.3.3, Apache 1.3.11, mod_perl 1.21
> 
> Any help greatly appreciated.
> 
> -- Jonathan
>