LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2003, 11:16 AM   #1
XxAndyxX
Member
 
Registered: Mar 2003
Location: Houston, TX
Distribution: RedHat 8.0
Posts: 79

Rep: Reputation: 15
Simple Perl prog. getting Error 500 message.


I was trying to just test a simple Perl/CGI script and I always seem to get this error even after I've tried chmod 775 and chmod 777.

This is my HTML...

<html><head><title>Post.html</title></head>
<body>

<form action="/cgi-bin/post.cgi" method="POST">
<pre>
Your Name: <input type="text" name="name">
Email Address: <input type="text" name="email">
Age: <input type="text" name="age">
Favorite Color: <input type="text" name="favorite_color">
</pre>
<input type="submit" value="Send">
<input type="reset" value="Clear Form">
</form>

</body>
</html>

My Perl/CGI script...

#!/usr/bin/perl

print "Content-type:text/html\n\n";

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;
}

print "<html><head><title>Form Output</title></head><body>";
print "<h2>Results from FORM post</h2>\n";

foreach $key (keys(%FORM)) {
print "$key = $FORM{$key}<br>";
}

print "</body></html>";

The Error message I get...

Server error!
The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: post.cgi
If you think this is a server error, please contact the webmaster
Error 500
xxandyxx.cjb.net
Sun 06 Jul 2003 08:18:16 AM EDT
Apache/2.0.40 (Red Hat Linux)


http://XxAndyxX.cjb.net/post.html
 
Old 07-06-2003, 11:25 AM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Im not sure abotu:
foreach $key (keys(%FORM)) {

I would use:
foreach $key (keys %FORM) {

You also don't end with:
exit;


Try using my error log checking script to get more info:
http://www.linuxquestions.org/questi...870#post269870
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl-CGI 500 Error tzarcone Programming 1 07-01-2005 02:45 AM
PERL error 500 --- ronkymac Linux - Software 4 02-19-2005 07:05 AM
2 simple shell prog questions provkitir Linux - Software 3 11-23-2004 03:00 AM
Something wrong with this simple hello world prog mandrakeroot Programming 9 08-26-2003 05:24 PM
PERL error trying to run simple HTML page.... vous Programming 1 08-25-2003 09:01 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:10 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration