Forum Moderators: coopster & phranque

Message Too Old, No Replies

FormMail.pl 500 error, premature end of script headers.

         

toys19

1:53 pm on Aug 9, 2007 (gmt 0)

10+ Year Member



I am trying to send form input from my website to my email address using formMail.pl which is installed here http://www.example.co.uk/cgi-bin/FormMail.pl
I just get the 500 internal server error.
I have tried testing the perl installation on the server using a simple script. This also returns the same error, suggesting that perl is not installed or not operational.I would really appreciate your help as I have tried everything I know here and I'm stuck.
Thanks in advance.

[edited by: jatar_k at 1:55 pm (utc) on Aug. 9, 2007]
[edit reason] no urls thanks [/edit]

rainborick

3:04 pm on Aug 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This error has three common causes: (1) a syntax error in the script itself, (2) the script file not being in the proper ASCII format with linefeeds used as the line termination character, (3) the permissions on the script file are not set to 755.

Scour the script for typographical errors. In particular, where you insert your own Email address, if the text is enclosed with double-quotes ("), make sure you put a backslash (\) in front of the @ in the address. Make sure you edit the script on your system with a plain text file editor like Windows Notepad and that you upload it in ASCII using your FTP program. The FTP program should also include a tool for setting the permissions. It should be set to 755 or -

Owner: Read, Write, Execute (RWX)
Group: Read, Execute (RX)
User: Read, Execute (RX)

toys19

4:17 pm on Aug 9, 2007 (gmt 0)

10+ Year Member



Hi thanks for your reply. Apart from the script mistakes I've done all the rest already, it was edited in PerlIDE, it had the windows carriage return endings stripped out, uploaded as ASCii using filezilla, permissions set to 755.
I've tried using the perl code below in a file called test.pl, and this does not work either. So I have a worry that there is a problem with the server rather than with any script. Should this test script below work?
#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "testing...\n";

Thanks

perl_diver

7:22 pm on Aug 9, 2007 (gmt 0)

10+ Year Member



if you did everything correct, the only problem with the code could be the shebang line is wrong:

#!/usr/bin/perl

normally if you use an FTP application to transfer the file from PC to server, you do not need to worry about changing the line endings. Upload the perl script is ascii format and the ftp application will change the line endings as needed during the transfer. You may have to tell the ftp application what type of server you are transfering to or select autodetect if it has that option available. See your ftp apps help files for details.

toys19

9:17 pm on Aug 9, 2007 (gmt 0)

10+ Year Member



Hi Thanks for the info, I will check out the ftp clinet (its filezilla) I know the shebang line is correct, I have that confirmed from my server host.
I'm stuck now, I think there is a problem with the server..

Any other ideas?

perl_diver

5:31 am on Aug 10, 2007 (gmt 0)

10+ Year Member



try using .pl and .cgi extension. It really should not matter but some servers might still be setup to only run one of those extensions, although it is a long shot. Check the server error log if possible. It may have a clue as to what the problem is but often times the error message is cryptic or too generic.

toys19

8:19 am on Aug 10, 2007 (gmt 0)

10+ Year Member



tried the pl and cgi endings, no joy. The error message from the server log is in my thread title, "premature end of script headers".
I've never run a script on this server before so I am suspicious that its a problem at the server end, any help or pointers would be gratefully received.
Thanks

perl_diver

9:16 am on Aug 10, 2007 (gmt 0)

10+ Year Member



if the basic "hello world" script does not run as a cgi, and the shebang line is correct, the permissions are correct, and you uploaded the script in the correct mode, it appears that the server has some issues. Even the header you used should work: text/plain, although for cgi scripts text/html is generally more appropriate. I guess you could try one last thing:

#!/usr/bin/perl
use CGI::Carp qw/fatalsToBrowser/;
print "Content-Type: text/html\n\n";
print "Hello World";

but the CGI::Carp module will not help if the shebang line is wrong, if the permissions are wrong, or the line endings are wrong.

toys19

9:42 am on Aug 10, 2007 (gmt 0)

10+ Year Member



I have tested my scripts on another server, with no problems and now have my html form submittting to that server just to handle the FormMail.pl bit and it redirects back to my success page, so happy days! The script definitely works, I think its just a server issue, thanks you guys for all your help! I'm off to beat my hoster with a large stick...

toys19

5:52 am on Aug 11, 2007 (gmt 0)

10+ Year Member



Quote from my server host:
The issue was caused by having SUEXEC setup on your web space, but the permissions were incorrect and therefore it failed. We have resolved those and it has resolved the problem with your scripts.

All that effort and there was nothing wrong with my script!