Premature end of script headers , error Given in simple registration form

Hi
Below is a perl scrift with permission 755 (I tried 666 also), that gives me the error : Premature end of script headers . It compiles fine on the machine when I run it with perl, but when I try to access it from the web ( at http://goose.cs.und.ac.za/registration.htm ), I get this error.

#!/usr/bin/perl

# the above line ensures that this file
# is interpreted as a perl program.

# load the common gateway interface (cgi) library.
push(@INC,"/var/www/cgi-bin");
require("cgi-lib.pl");

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

# parse the parameters from the html form
# and load them into the associative array, $in.
&ReadParse;

# get inputs from $in
$username = $in{'USERNAME'};
$password = $in{'PASSWORD'};
$email = $in{'EMAIL'};
$name = $in{'NAME'};
$surname = $in{'SURNAME'};
$graduationyr = $in{'GRADUATIONYR'};
$checks = $in{'CHECKBOX'};

open(LOG,">>/var/www/cgi-bin/Tester.log");
print LOG "$in{'name'}\n";
foreach $CHECK (@CHECKBOX) {print LOG "$CHECK \n"; }

close (LOG);

print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Computer Science Old Boys</TITLE>\n";
print "</HEAD>\n";
print "<BODY bgcolor='#ffffff'>\n";
print "\n";
print "<H1>Thankyou for registering</H1>";
print "$name ,please visit uis soon \n";
print "</BODY>\n";
print "</HTML>\n";



Any ideas
zaidmoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

dutchfoxerCommented:
Try CHMOD 664.

Also if you FTP-ed it, use ascii ftp, not binary. Hope it helps.... let me know, otherwise more solutions available.
xDamoxCommented:
Hi zaidmo,


Why not delete the lines:

# load the common gateway interface (cgi) library.
push(@INC,"/var/www/cgi-bin");
require("cgi-lib.pl");

and just replace them with:

use CGI qw(:standard);

also instead of using &ReadParse; delete that line and replace them with:

$username = param('USERNAME');
$password = param('PASSWORD');
$email = param('EMAIL');
$name = param('NAME');
$surname = param('SURNAME');
$graduationyr = param('GRADUATIONYR');
$checks = param('CHECKBOX');

this will make the code better so overall it show look like:


#!/usr/bin/perl

# the above line ensures that this file
# is interpreted as a perl program.

# load the common gateway interface (cgi) library.
use CGI qw(:standard);

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

# get inputs from $in
$username = param('USERNAME');
$password = param('PASSWORD');
$email = param('EMAIL');
$name = param('NAME');
$surname = param('SURNAME');
$graduationyr = param('GRADUATIONYR');
$checks = param('CHECKBOX');

open(LOG,">>/var/www/cgi-bin/Tester.log");
print LOG "$in{'name'}\n";
foreach $CHECK (@CHECKBOX) {print LOG "$CHECK \n"; }

close (LOG);

print "<HTML>\n";
print "<HEAD>\n";
print "<TITLE>Computer Science Old Boys</TITLE>\n";
print "</HEAD>\n";
print "<BODY bgcolor='#ffffff'>\n";
print "\n";
print "<H1>Thankyou for registering</H1>";
print "$name ,please visit uis soon \n";
print "</BODY>\n";
print "</HTML>\n";


and if you are in your Unix/Linux shell you will do chmod +x script
also make sure this script is in the cgi-bin directory.

hope this helps

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ManasBhattCommented:
-------------------------------------------
push(@INC,"/var/www/cgi-bin");
require("cgi-lib.pl");
---------------------------------------

might be the source of problem, just check if the cgi-lib.pl compiles fine ie perl -c cgi-lib.pl. Also check if you are returning 1 as the last line in cgi-lib.pl because require needs  last statement to be true.  Also check if cgi-lib.pl is not printing anything to stdout.

finally it would be better off using CGI module as xDamox has suggested.
-manas
dkin69Commented:
Try replacing this

#!/usr/bin/perl

With This

#!/usr/bin/perl - w

That works all the time for me
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.