Catching Apache error with a Perl script

Discussion in 'Perl' started by PapaBear, Aug 20, 2003.

  1. PapaBear

    PapaBear Guest

    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!
     
    PapaBear, Aug 20, 2003
    #1
    1. Advertising

  2. PapaBear

    PapaBear Guest

    Brian Wakem <> schreef in berichtnieuws
    bhvku6$3m44b$-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
     
    PapaBear, Aug 20, 2003
    #2
    1. Advertising

  3. PapaBear

    Tony Guest

    "PapaBear" <> 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
     
    Tony, Aug 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Wet Basement
    Replies:
    1
    Views:
    2,543
    BobMonk
    Jul 15, 2003
  2. dpackwood
    Replies:
    3
    Views:
    1,829
  3. PapaBear
    Replies:
    2
    Views:
    98
  4. The Poor
    Replies:
    2
    Views:
    244
    Gregory Toomey
    Sep 27, 2003
  5. Selmar
    Replies:
    2
    Views:
    188
    krakle
    Jul 21, 2004
Loading...

Share This Page