homepage Welcome to WebmasterWorld Guest from 107.20.25.215
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

This 44 message thread spans 2 pages: < < 44 ( 1 [2]     
Newbies need help with Perl script please
daro2008




msg:3698093
 4:35 pm on Jul 14, 2008 (gmt 0)

Hi all,

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

 

perl_diver




msg:3700061
 6:13 pm on Jul 16, 2008 (gmt 0)

chmod the cgi-bin to have permissions for:

owner - read write execute
group - read execute
other - read execute

that would be chmod 755 or use the control panel to set the permissions or an FTP application.

daro2008




msg:3700233
 9:15 pm on Jul 16, 2008 (gmt 0)

Hi Perl_driver,

Yes I did chmod the cgi-bin to have permissions for:

owner - read write execute
group - read execute
other - read execute

There is still no luck.

Any advice?

perl_diver




msg:3700302
 10:19 pm on Jul 16, 2008 (gmt 0)

Get a new host, this is ridiculous.

phranque




msg:3700338
 11:30 pm on Jul 16, 2008 (gmt 0)

does your technician's test script still work?
if so then make a backup copy and replace its contents with the hello script.
then GET that url and see if it still works...

rocknbil




msg:3700401
 12:55 am on Jul 17, 2008 (gmt 0)

<Throws in two cents> daro2008, what phranque is trying to determine is whether or not you can get **ANY** script to run on your server. We can simplify it even more:

#!/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.

perl_diver




msg:3701168
 9:19 pm on Jul 17, 2008 (gmt 0)

ditch the host, if this is such a pain in the ass I can only predict there will be plenty of problems elsewhere with this host.

daro2008




msg:3701599
 12:34 pm on Jul 18, 2008 (gmt 0)

Many thans for all.

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

phranque




msg:3702004
 8:14 pm on Jul 18, 2008 (gmt 0)

that seems like an obscure problem/solution.

does your ErrorDocument now get served properly?
i would try purposely putting an error in your script so you can test this.

daro2008




msg:3702584
 6:59 pm on Jul 19, 2008 (gmt 0)

I dont know what the technician did. I did try to set permission to 755 in the previous discussion; but it did not work. And then the technician email saying that he tested a simple perl script hell.cgi sucessfully by setting permission to 755 instead of 775. I tried this again for my guest book script - it works perfectly as before.

Many thanks for all your support.

phranque




msg:3702746
 12:49 am on Jul 20, 2008 (gmt 0)

does your ErrorDocument now get served properly?
have you tested a 404?

daro2008




msg:3703116
 11:14 pm on Jul 20, 2008 (gmt 0)

phranque,

I dont know where to find ErroDocument?

perl_diver




msg:3703166
 1:15 am on Jul 21, 2008 (gmt 0)

They will need to setup the error document using whatever method the server has setup for that. Normally you do it in the user control panel or there might be instructions on how to make one and what to call it and where to store it on the server. It used to be that 404.html or 404.shtml (for example) would be saved in the root folder and the server would find it. But that is not always the case.

phranque




msg:3703869
 8:38 pm on Jul 21, 2008 (gmt 0)

you can easily test a 404 error by requesting a non-existent url.
for example, GET:
http://www.example.com/some-nonsense-filename.html

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

daro2008




msg:3705165
 9:05 am on Jul 23, 2008 (gmt 0)

Hi Phranque,

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]

This 44 message thread spans 2 pages: < < 44 ( 1 [2]
Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved