Premature end of script headers

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Premature end of script headers

Post 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?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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 ;)
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post 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 :)
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post 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.
Post Reply