Results 1 to 5 of 5

Thread: Error404? Code doesn't work

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Error404? Code doesn't work

    Hi guys, another question about CGI/Perl, the code is below:

    #!/usr/bin/perl
    use CGI qw(:standard);
    #use strict;
    use Fcntl qw(:flock :seek);

    # the Content-type header is required even if nothing else is printed.
    print header;

    # open file for appending
    open(OUT,">>errlog.txt") or exit;
    flock(OUT,LOCK_EX);
    seek(OUT,0,SEEK_END);
    print OUT "uri: $ENV{REQUEST_URI}, referer: $ENV{HTTP_REFERER}\n";
    close(OUT);

    When I uploaded it my CGI-BiN, it seemed the page is blank. It didn't show anything besides writing it to my counts.txt. But the example on that website has something, here is the link of that
    http://www.cgi101.com/book/ch8/

    When you click on that err404.html, it shows error page. I believe that's my target; however, my page is simply blank. Any idea or additional code to work on?

    I'm so perplexed about this, any helps might be much appreciated.

    Thanks.

  2. #2
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Error404? Code doesn't work

    I'm not sure why you commented out the "use strict" but suspect it's because it was raising an error saying something about Fcntl or header?

    For starters, I'd need to verify that the Fcntl module is in place and that "print header" is valid (perhaps it is in mod_perl but it isn't in standard perl). Other than whatever "print header" should be sending to the browser there isn't any other output directed to the browser. Perhaps you could, from the command line, run "perl -c script_name" and have perl provide you with the problem.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: Error404? Code doesn't work

    The site ran fine without giving me any Internal Error. I've been told by cgi101 that use strict is optional. My host didn't accept that module, so that's why I commented it out.

    I ran the uploaded cgi file, but the thing is it gives me blank page without giving me any error codes. But on that cgi101.html, they give me words like "error404..." I want that.

    Further help? My errorlog.txt wrote this uri: $ENV{REQUEST_URI}, referer: $ENV{HTTP_REFERER} whenever I execute that code. *sigh*

  4. #4
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: Error404? Code doesn't work

    Some versions of Perl require that you use single qoutes inside of the brackets when specifying environmentals - i.e. $ENV{'HTTP_REFERER'} - if that doesn't work I'm totally lost.

    Also, totally confused as to who would install Perl without including core components, such as strict, but other than that cgi101 is correct in saying it is optional but it's use will prevent scoping errors, etc (similar to Option Explicit in VB).

    You need to direct some output to the browser via the print command - after you've printed the errorlog enter another line printing anything - I tend to use something like "Print "1\n";", etc, so I can determine where the script is dying at.

    If you get an internal error when trying to print some text that's an indication that the "print header" line isn't working and the script doesn't know what/where to send the output. In that case replace the "print header" line with "print "Content-type: text/html\n\n";" and try the script again.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2005
    Posts
    1,170

    Re: Error404? Code doesn't work

    anotherVBnewBie, I guess I give up this question at this forum. *sigh*

Posting Permissions

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



Click Here to Expand Forum to Full Width