FAQ
I am in the process of logging referring URLs that result in end users
being directed to a 4xx error page. What I have noticed is that other
items such as a missing CSS, a reference to a non-existing image, etc.
that does not necessarily result in the user seeing the 4xx page is
still makes an entry in my log file. What I am looking for is a
parameter that I can add to my PERL script that will specify the file
call that resulted in the log entry.



Thanks,


Steve
-----------------------------------
Steve Hildreth
Office: 213-241-1691
Cell: 213-215-8195
steve.hildreth@lausd.net <blocked::mailto:steve.hildreth@lausd.net>

Search Discussions

  • Gunnar Hjalmarsson at May 12, 2008 at 7:11 pm

    Hildreth, Steve wrote:
    What I am looking for is a parameter that I can add to my PERL script
    that will specify the file call that resulted in the log entry.
    How about showing us the Perl (not PERL) script you have so far?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
  • Hildreth, Steve at May 12, 2008 at 7:15 pm
    Of course, here it is...very simple.

    #!/usr/local/bin/perl

    # This script is used to log the referring URL in the event that a link
    on an LAUSD is invalid

    #Append referring URL to log file
    open(LIST,">>/www-logs/error_file.txt");

    #Capture referring URL
    $_ = $ENV{'HTTP_REFERER'};

    #Determine if originating page belongs to LAUSD
    if(!/notebook.lausd.net|.gif|.css|aw:|google.com|myspace.com|.gif|.jpg/)
    {
    print LIST "$_\n";
    }
    close (LIST);

    #Redirect user to standard error page
    print "Content-type: text/html\n\n";
    print "<meta HTTP-EQUIV=\"Refresh\"
    CONTENT=\"0;URL=http://www.lausd.net/error.html\">";

    Thanks,


    Steve
    -----------------------------------
    Steve Hildreth
    Office: 213-241-1691
    Cell: 213-215-8195
    steve.hildreth@lausd.net


    -----Original Message-----
    From: Gunnar Hjalmarsson
    Sent: Monday, May 12, 2008 12:13 PM
    To: beginners@perl.org
    Subject: Re: log missing images

    Hildreth, Steve wrote:
    What I am looking for is a parameter that I can add to my PERL script
    that will specify the file call that resulted in the log entry.
    How about showing us the Perl (not PERL) script you have so far?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org
    http://learn.perl.org/
  • Gunnar Hjalmarsson at May 12, 2008 at 8:34 pm
    [ Please don't top-post! ]

    Hildreth, Steve wrote:
    Gunnar Hjalmarsson wrote:
    Hildreth, Steve wrote:
    What I am looking for is a parameter that I can add to my PERL script
    that will specify the file call that resulted in the log entry.
    How about showing us the Perl (not PERL) script you have so far?
    Of course, here it is...very simple.

    #!/usr/local/bin/perl

    # This script is used to log the referring URL in the event that a link
    on an LAUSD is invalid

    #Append referring URL to log file
    open(LIST,">>/www-logs/error_file.txt");

    #Capture referring URL
    $_ = $ENV{'HTTP_REFERER'};

    #Determine if originating page belongs to LAUSD
    if(!/notebook.lausd.net|.gif|.css|aw:|google.com|myspace.com|.gif|.jpg/)
    {
    print LIST "$_\n";
    }
    close (LIST);
    Okay...

    To see the available env variables, do:

    print "Content-type: text/plain\n\n";
    print "$_ = $ENV{$_}\n" for keys %ENV;

    Maybe you are looking for $ENV{REDIRECT_REQUEST_URI} (for the case it's
    available).
    #Redirect user to standard error page
    print "Content-type: text/html\n\n";
    print "<meta HTTP-EQUIV=\"Refresh\"
    CONTENT=\"0;URL=http://www.lausd.net/error.html\">";
    This is a better way to redirect from a CGI script:

    print "Location: http://www.lausd.net/error.html\n\n";

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMay 12, '08 at 6:42p
activeMay 12, '08 at 8:34p
posts4
users2
websiteperl.org

People

Translate

site design / logo © 2022 Grokbase