Page 1 of 1

Premature end of script headers

Posted: Sun Mar 05, 2006 3:29 pm
by chrys
Searched around can't find solution.. but I have a simple script:

Code: Select all

#!/usr/local/bin/perl
use CGI;
my $query= new CGI;
print $query->header;
print "hello people in my head\n";
When I view it via web browser I get a Internal Server Error 500.

When I run it via shell:

Code: Select all

> perl perl.cgi
Content-Type: text/html; charset=ISO-8859-1

hello people in my head
Any ideas?

Posted: Sun Mar 05, 2006 3:43 pm
by Chris Corbyn
The internal server error (500) usually means that apache couldn't execute the file.

Did you set the "execute" bit for it? "CHMOD 0777" would guarantee that ;)

Posted: Sun Mar 05, 2006 3:45 pm
by Chris Corbyn
Oh... and by the way. By typing "perl" in the command line you're by-passing the shebang line.

Type:

./scriptname.cgi

That will give you an error in the command line if the shebang is wrong or it's not executable ;)

Posted: Sun Mar 05, 2006 3:51 pm
by chrys
Thanks man. Wow I just pulled an amateur move lol, I didn't make it executable!

I haven't done perl in so long, I'm mainly a PHP man now. But a client requested this as a perl script, so it's time to dip my feet again :)

Posted: Sun Mar 05, 2006 4:03 pm
by Chris Corbyn
chrys wrote:Thanks man. Wow I just pulled an amateur move lol, I didn't make it executable!

I haven't done perl in so long, I'm mainly a PHP man now. But a client requested this as a perl script, so it's time to dip my feet again :)
And you love it! :P

Perl is great. I still dabble in it from time to time because I just love its funky regex magic :D Great for CLI scripts too, although I can do cool things with PHP and Ncurses now.