perl subroutine will not work with NCSA httpd 
Author Message
 perl subroutine will not work with NCSA httpd

I have just determine that  I have a problem with perl scripts running
as CGI scripts. If I call a subroutine that has been defined in a
required file, I receive an error code of 500 from the server.

Here is a snipet of my (elementary) code:

require './cgi-handlers.pl';

&html_header ('LANVan Schedule');  

If this is in the perl script when executed by the server, it fails. If I
comment out the html_header line and replace it with a print statement,
it works fine. Even if the require is still in the file it is fine.

What am I missing?
--
                                        Gerard.
-------------------------------------------------------------------

Cabletron Systems, Inc.                 +1 603 337 3650



Mon, 10 Feb 1997 06:04:07 GMT  
 perl subroutine will not work with NCSA httpd

    GH> I have just determine that I have a problem with perl scripts
    GH> running as CGI scripts. If I call a subroutine that has been
    GH> defined in a required file, I receive an error code of 500
    GH> from the server.

I had similar problems, until I realized that the perl script was
being run from the top of the filesystem.  To get the script to change
back to the directory you think it's in, use something like:

chdir($1) if $0=~/(.*)\/[^\/]*$/;

--
                                                         =[ cooper ]=



Mon, 10 Feb 1997 10:26:26 GMT  
 perl subroutine will not work with NCSA httpd

Quote:

>I have just determine that  I have a problem with perl scripts running
>as CGI scripts. If I call a subroutine that has been defined in a
>required file, I receive an error code of 500 from the server.
>Here is a snipet of my (elementary) code:
>require './cgi-handlers.pl';
>&html_header ('LANVan Schedule');  
>If this is in the perl script when executed by the server, it fails. If I
>comment out the html_header line and replace it with a print statement,
>it works fine. Even if the require is still in the file it is fine.
>What am I missing?
>--

Almost anything can cause a 500 error from the server.  I got it because
I was missing a closing parenthesis for an if-statement in my perl script.
Of course it could be something other than syntax, but it's worth a check
anyway.

Chad



Mon, 10 Feb 1997 22:18:10 GMT  
 perl subroutine will not work with NCSA httpd

Quote:

>Here is a snipet of my (elementary) code:
>require './cgi-handlers.pl';
>&html_header ('LANVan Schedule');  
>If this is in the perl script when executed by the server, it fails. If I
>comment out the html_header line and replace it with a print statement,
>it works fine. Even if the require is still in the file it is fine.
>What am I missing?

Possibly the pwd when the CGI script is run...

If cgi-handlers.pl is not in '.' when run as a CGI script, it won't know
how to '&html_header', and exit with "Undefined subroutine...".

Best to put it in /usr/local/lib/perl (as used on your system), or push the

Good luck,
philip

____________________________________________________________ Philip Kizer ___

"Relying on the government to protect your privacy is like asking a peeping
tom to install your window blinds." -John Perry Barlow, EFF co-founder



Mon, 10 Feb 1997 22:18:19 GMT  
 perl subroutine will not work with NCSA httpd

Quote:

>If this is in the perl script when executed by the server, it fails. If I
>comment out the html_header line and replace it with a print statement,
>it works fine. Even if the require is still in the file it is fine.
>What am I missing?

Does the perl library return 1 (true)?  A 1 is required as the last
executable statement in a perl library.




Wed, 12 Feb 1997 00:32:25 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Perl to write to NCSA httpd .htpasswd file ?

2. Perl can choke NCSA httpd?

3. ncsa httpd setup for perl scripts

4. NCSA Httpd Error 500

5. Executing *.pl on NCSA httpd server

6. A script to summarize NCSA HTTPd error logs to text or html3

7. NCSA Httpd Error 500

8. LD_LIBRARY PATH and the CERN and NCSA HTTPD

9. DBI/DBD connection works in shell, not httpd

10. references to subroutines and sort() - not working ?

11. prototyping subroutines...not working

12. mod_perl-module-subroutine: not working well with web server

 

 
Powered by phpBB® Forum Software