I am very new here today. I have a problem with running a perl script which results in displaying the following message:
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request
The Perl Script for my small Guest book is:
#!/usr/bin/perl
# That is the path to PERL just above It MUST be first in the script
# The following accepts the data from the form
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}
# The following sends the email
open (MESSAGE,"¦ /usr/sbin/sendmail -t");
print MESSAGE "To: $FORM{submitaddress}\n";
print MESSAGE "From: $FORM{surName}\n";
print MESSAGE "Reply-To: $FORM{email}\n";
print MESSAGE "Subject: Feedback from $FORM{lastName} at Itwebxpert\n\n";
print MESSAGE "Surname: $FORM{lastName}\n";
print MESSAGE "First name: $FORM{firstName}\n";
print MESSAGE "email: $FORM{email}\n";
print MESSAGE "Sex: $FORM{sex}\n";
print MESSAGE "The user wrote:\n\n";
print MESSAGE "$FORM{message}\n";
close (MESSAGE);
&thank_you;
}
#The following creates the Thank You page display
sub thank_you {
print "Content-type: text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>Thank You Page</title>\n";
#link to external style sheet file: style1.css
print "<link rel=\"StyleSheet\" name=\"style\" href=\"../styles/style2.css\" type=\"text/css\">";
print "</head>\n";
print "<body>\n";
print "<h1><center>Your message has been sent</center></h1><hr>";
print "<h2 align=\"center\">Thank You!</h2>\n";
print "\n";
print "<h3 align=center>Your feedback is greatly appreciated?</h3><hr><br>";
print "<center><a class=\"declink\" href=\"../personal/personal.html\">Back to home page</a></center>\n";
print "</body>\n";
print "</html>\n";
exit(0);
}
I check the path to the Perl server is correct, and the path from my HTML guest book form to this script file is also correct. The Script work previously in my previous webhosting server, but it does not work at the current webhosting server. The technician of the current webhosting said there is something wrong with the script, but I denied as it worked before. Just to make sure the script is correct, could anyone here check if there is any thing missing from the script above.
Your kind help is very appreciated.
Regards
Daro2008
#!/usr/bin/perl
print "content-type:text/html\n\n";
print "Hello world";
Put that in a plain text file, save it as hello.cgi, upload it, set permissions, see if it will run. If this doesn't run, it's very likely the transfer mode/EOL issues I discussed.
If that works, go back to his hello world script and figure out why it won't run.
Finally, it works - The technician possibly fixed errors in perl server. The permission to the .cgi or .pl files and cgi-bin folder must be set to 755 not 775 as used by most Perl Server.
I found this website is very useful for technical discussion/help.
Many thanks again for all.
Cheers
Many thanks for all your support.
then you can easily test a 500 error by purposely introducing a perl syntax error in your script and then requesting that script in the url.
http://www.example.com/script-with-a-syntax-error.cgi
thank you for your great advice. I try to to test a non-existen url, and get the following result:
The webpage cannot be found
HTTP 404
Most likely causes:
There might be a typing error in the address.
If you clicked on a link, it may be out of date.
What you can try:
Retype the address.
Go back to the previous page.
Go to and look for the information you want.
More information
the title of the above HTML page is: HTTP 404 Not Found.
------------------------
and I tested an error perl script with the result as follows:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@example.co.uk and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
But the title of the above HTML page is: 500 Internal server error
--------------------
The server is correct now?
Cheers
[edited by: phranque at 8:18 pm (utc) on July 24, 2008]
[edit reason] examplified domain [/edit]