473,513 Members | 11,702 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching Apache error with a Perl script

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!

Jul 19 '05 #1
2 2497
Brian Wakem <no@email.com> schreef in berichtnieuws
bh************@ID-112158.news.uni-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


Jul 19 '05 #2
"PapaBear" <Pa******@Filternet.nl> 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
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2086
by: Karl A. Krueger | last post by:
I'm in the middle of refactoring a small mod_python Web application, which uses the Publisher handler. This application is currently a single main Python file (which loads several other files as...
1
1950
by: Harrie Geerts | last post by:
attempt to invoke directory as script: c:/foxserv/www/cgi-bin This is standing in error.log Apache. Das steht in error.log Apache. And I get: Und ich bekomme: Forbidden.
1
4713
by: Sergio | last post by:
I'm writing a cgi script that uses graphviz (the dot program) to generate a graph and I'm banging my head against the wall trying to get it to work properly. Currently, if I run the script directly...
3
1478
by: Arvin Portlock | last post by:
I've written a perl cgi script but it's too slow so I need to rewrite it in C++. The perl script passes parameters to a search engine on our local filesystem and processes the results (number of...
6
3942
by: Michael L. Artz | last post by:
I'm having some odd issues, but I'm not sure exactly the cause of them, but postgres is the component in the system that is throwing the errors, so I thought I'd start here. I have built a web...
4
6906
by: liyanage | last post by:
I recently worked on error handling and three related issues/questions came up. 1.) I am trying to trigger Apache ErrorDocument handlers by setting appropriate HTTP status codes in my PHP...
6
7958
by: MaiyaHolliday | last post by:
Hello, I've recently installed apache on a new computer, and cannot figure out why my site will not process any includes. (it was working on my old one) There are no errors on the page such as...
0
6833
by: phil469 | last post by:
I'm having an issue when trying to read a file in a user's homedir from a cgi script. I have a virtual host section in my httpd.conf file which I'll include. The cgi script is a very basic script...
10
6933
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration...
0
7153
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7373
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7432
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7094
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5677
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5079
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3230
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3218
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.