473,725 Members | 2,127 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 2505
Brian Wakem <no@email.com > schreef in berichtnieuws
bh************@ ID-112158.news.uni-berlin.de...

my ($error_number) = $ENV{QUERY_STRI NG} =~ /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******@Filte rnet.nl> wrote in message news:<bhvk23$d5 6$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
2098
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 modules) with several function entry points for the different pages in the application. (The application is a tool to allow staff members here to request firewall port openings for their servers. Thus there is a page (and function) for "view...
1
1960
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
4723
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 from the command line, it will work properly and generate my graph (which gets dumped into a file). If I invoke the script as a cgi script within apache, it runs fine until it calls the as_png() function, at which point it will die waiting for a...
3
1488
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 hits, etc.). I've never had to do anything like this in C++ before and I don't know where to start. So what is the equivalent in C++ to something like this? open (RESULTS, "srch -q $word |"); Which is the perl method of opening a handle on the...
6
3960
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 application that uses postgres (7.3.2) as its backend, with the front being an Apache2/mod_perl solution. I've printed what I think the relevant versions are below. Anway, DBD::Pg throws random errors into my logs, along the lines of what is...
4
6964
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 code, but I don't get the expected results. My PHP file:
6
7978
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 "include not found", rather much of the page is blank where the included menus, etc would be, and the CSS is not attached. thanks so much!!! My httpd.conf looks like this:
0
6855
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 written in Perl just for testing. I believe I need to find the correct <Directory> entry or some other Directive in Apache to make this work, but I've had no luck for a week now. I've tried many different things, but w/ no luck. I even tried adding...
10
6975
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 of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8888
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8752
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9401
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9176
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9113
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8097
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3221
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.