Catching Apache error with a Perl script

Ask a Question related to PERL Miscellaneous, Design and Development.

  1. #1

    Default 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 [url]http://levi.prodeo/errors/err_403.shtml[/url]
    ErrorDocument 404 [url]http://levi.prodeo/errors/err_404.shtml[/url]
    ErrorDocument 405 [url]http://levi.prodeo/errors/err_405.shtml[/url]

    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 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=403[/url]
    ErrorDocument 404 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=404[/url]
    ErrorDocument 405 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=405[/url]

    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------
    [url]http://www.geekcode.com[/url]
    __________________________________
    Never mind the bear, beware of Papa!



    PapaBear Guest

  2. Similar Questions and Discussions

    1. catching script errors in PSQL and redirecting to file?
      Hi, I have a problem catching the output of my scripts into the file. For example I have a set of scripts to create my schema. In psql I just...
    2. Apache returns 200 OK, but my perl script sends 302 REDIRECT
      On Thu, Aug 21, Michel Tokic inscribed on the eternal scroll: If you were sure about that, then why ask here? (i.e c.l.p.m)....
    3. Strange INC error when using perl 5.8.0 as a cgi script
      Hi All, I have just compiled perl 5.8.0 on aix 4.3.3. I got the stable.tar from cpan. It complied fine without any errors. The trouble starts...
    4. Apache mod_rewrite/RewriteMap prg: and perl script
      Sorry for the x-posting, but sometimes I just gotta do it! So many redundant-seeming newsgroups and all... Anyways, I have a server as follows:...
    5. Problem executing a BAT file (or EXE file) using Perl as CGI script under Apache.
      I have developed some perl code to run as a script under Windows 2000 running apache. This works GREAT on Win2k but on WinNT, perl is simply...
  3. #2

    Default Re: Catching Apache error with a Perl script

    Brian Wakem <no@email.com> schreef in berichtnieuws
    bhvku6$3m44b$1@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------
    [url]http://www.geekcode.com[/url]




    PapaBear Guest

  4. #3

    Default Re: Catching Apache error with a Perl script

    "PapaBear" <Papabear@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 [url]http://levi.prodeo/errors/err_403.shtml[/url]
    > ErrorDocument 404 [url]http://levi.prodeo/errors/err_404.shtml[/url]
    > ErrorDocument 405 [url]http://levi.prodeo/errors/err_405.shtml[/url]
    >
    > 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 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=403[/url]
    > ErrorDocument 404 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=404[/url]
    > ErrorDocument 405 [url]http://levi.prodeo/cgi-bin/http_err.pl?err=405[/url]
    >
    > 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------
    > [url]http://www.geekcode.com[/url]
    > __________________________________
    > Never mind the bear, beware of Papa!


    if you are calling the page like [url]http://levi.prodeo/cgi-bin/http_err.pl?err=405[/url]
    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
    Tony Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139