LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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 04-07-2004, 02:13 AM   #1
amit_28oct
Member
 
Registered: Feb 2004
Posts: 31

Rep: Reputation: 15
Help required in perl.


While running Perl programs I frequently face following error message
When I try to run it from browser. as http://localhost/cgi-bin/loan.pl

Server error!

The server encountered an internal error and was unable to complete your request.

Error message:
Premature end of script headers: loan.pl

If you think this is a server error, please contact the webmaster

Error 500

localhost
Wed 07 Apr 2004 11:42:44 AM IST
Apache/2.0.40 (Red Hat Linux)

When I view the error log then their I always get common error message i.e
Premature end of script headers: loan.pl

Here point to be noted is that I can run the same program from terminal without any error messages. I tried -wc option as well. And it told me .syntax ok.

Also I have added proper content-type header in my program.
Permission for file is set to 755.

Any body have a clue why this happens ?
what exactly premature end of script header means ?
From where I can see description of this error message ?

Regards
Amit
 
Old 04-07-2004, 08:35 AM   #2
el-512
LQ Newbie
 
Registered: Mar 2004
Posts: 3

Rep: Reputation: 0
Not sure,
but I had a similar problem: Could not run the Perl script directly, but
perl<space><Script>
worked. When I gave the script Execute rights, everything was fine. Try
chmod 777
Does it work?

Markus
 
Old 04-07-2004, 08:46 AM   #3
ssba
Member
 
Registered: Mar 2004
Distribution: Slackware 9.1
Posts: 44

Rep: Reputation: 15
Are you printing correct headers? To view a script in a browser you need to print out a Content-type header, using one of the two ways below:

Code:
print "Content-type: text/html\n\n";
or the RFC-compliant header:
Code:
use CGI;
print CGI->header('text/html');
 
Old 04-07-2004, 10:24 AM   #4
sphink
LQ Newbie
 
Registered: Apr 2004
Location: U.S.A.
Distribution: Slackware 9.1, Astaro
Posts: 13

Rep: Reputation: 0
At the top of the script where you specify the Perl executable, also do this:

#!/usr/bin/perl --

Some servers will not actually execute a Perl script until they see the trailing "--".
 
Old 04-07-2004, 10:33 AM   #5
Komakino
Senior Member
 
Registered: Feb 2004
Location: Somerset, England
Distribution: Slackware 10.2, Slackware 10.0, Ubuntu 9.10
Posts: 1,938

Rep: Reputation: 54
Quote:
Originally posted by ssba
Are you printing correct headers? To view a script in a browser you need to print out a Content-type header, using one of the two ways below:

Code:
print "Content-type: text/html\n\n";
or the RFC-compliant header:
Code:
use CGI;
print CGI->header('text/html');
simply: print (header());

will do all that for you.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
checking for XML::Parser... configure: error: XML::Parser perl module is required for kornerr Linux - General 11 11-16-2008 08:24 AM
perl script help required to create users and changing the owner to pericular folder sridhar11 Programming 2 10-25-2005 03:16 PM
XML::Parser perl module is required for intltool, for LogJam GT_Onizuka Linux - Newbie 7 06-30-2005 08:49 AM
problems with xmltv required perl modules bacdog Linux - Software 0 12-25-2004 11:29 AM
XML::Parser perl module is required farzan Linux - Software 8 09-26-2004 06:54 AM


All times are GMT -5. The time now is 09:34 AM.

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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration