Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Catching Apache error with a Perl script

Reply
Thread Tools

Catching Apache error with a Perl script

 
 
PapaBear
Guest
Posts: n/a
 
      08-20-2003
Hi y'all,

I'm handling Apache errors through seperate shtml files. That surely looks
better than the standard error pages by the browser etc. I did this by
coding in httpd.conf lines like:

ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml
ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml
ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml

etcetera.


Now, I would like to handle those through a Perl script file.
For that purpose I coded in httpd.conf lines like:

ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=403
ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=404
ErrorDocument 405 http://levi.prodeo/cgi-bin/http_err.pl?err=405

It does not complain about this URL, but the big question is:

How do I get that error number into my Perl program?


Please spare me the CPAN modules, I think they're overweight. I'd like to
see what I'm coding, so simple solutions if possible...

Tnx in advance,

PapaBear

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
!e h---- r+++ y?
------END GEEK CODE BLOCK------
http://www.geekcode.com
__________________________________
Never mind the bear, beware of Papa!



 
Reply With Quote
 
 
 
 
PapaBear
Guest
Posts: n/a
 
      08-20-2003
Brian Wakem <(E-Mail Removed)> schreef in berichtnieuws
bhvku6$3m44b$(E-Mail Removed)-berlin.de...
>
> my ($error_number) = $ENV{QUERY_STRING} =~ /err=(\d+)/;
>


That works like a charm, tnx a lot Brian!

___________________________________
Never mind the Bear, beware of papa...

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
!e h---- r+++ y?
------END GEEK CODE BLOCK------
http://www.geekcode.com




 
Reply With Quote
 
 
 
 
Tony
Guest
Posts: n/a
 
      08-20-2003
"PapaBear" <(E-Mail Removed)> wrote in message news:<bhvk23$d56$1@news>...
> Hi y'all,
>
> I'm handling Apache errors through seperate shtml files. That surely looks
> better than the standard error pages by the browser etc. I did this by
> coding in httpd.conf lines like:
>
> ErrorDocument 403 http://levi.prodeo/errors/err_403.shtml
> ErrorDocument 404 http://levi.prodeo/errors/err_404.shtml
> ErrorDocument 405 http://levi.prodeo/errors/err_405.shtml
>
> etcetera.
>
>
> Now, I would like to handle those through a Perl script file.
> For that purpose I coded in httpd.conf lines like:
>
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=403
> ErrorDocument 404 http://levi.prodeo/cgi-bin/http_err.pl?err=404
> ErrorDocument 405 http://levi.prodeo/cgi-bin/http_err.pl?err=405
>
> It does not complain about this URL, but the big question is:
>
> How do I get that error number into my Perl program?
>
>
> Please spare me the CPAN modules, I think they're overweight. I'd like to
> see what I'm coding, so simple solutions if possible...
>
> Tnx in advance,
>
> PapaBear
>
> -----BEGIN GEEK CODE BLOCK-----
> Version: 3.1
> GAT/CS/CM/O d+(--) s++:+>: a? C++(+++)$ UL++(+++) P++>+++ L++>+++ E- W+++$
> N++ !o !K w !O M- V? PS->$ PE+(-) Y+ PGP t+ 5? !X R- tv b+(+++) DI? !D G(-)
> !e h---- r+++ y?
> ------END GEEK CODE BLOCK------
> http://www.geekcode.com
> __________________________________
> Never mind the bear, beware of Papa!




if you are calling the page like http://levi.prodeo/cgi-bin/http_err.pl?err=405
I would have though that you could just do something like this

#!/usr/bin/perl

use CGI qw(:standard);

$ErrorCode = param('err');

## do what ever on value of $ErrorCode


Regards

Tony
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
starting apache with mod_perl, error on Apache.pm Selmar Perl Misc 2 07-21-2004 09:53 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to test speed difference of Perl/Apache and SSI/Apache The Poor Perl Misc 2 09-27-2003 12:26 PM
Catching Apache error with a Perl script PapaBear Perl Misc 2 08-20-2003 12:56 PM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments