Gossamer Forum
Home : General : Perl Programming :

premature end of script headers

(Page 1 of 2)
> >
Quote Reply
premature end of script headers
hi everybody and please excuse my bad english,
i posted a message in links installation - unix saying that i get in the error log this message every time i try to access the admin cgi on my browser. i just realize today that i get the same error message every time I try to run a cgi script. not even a script that prints "hello world" is working.
i will paste the apache (i run a red hat 7.0 box) error log, naybe you can help me. thanks in advance and marry christmas. i also got to tell you that i tried to run this scripts as root but also as a regular user with same effect.
[Wed Dec 20 14:45:29 2000] [error] (2)No such file or directory: exec of /var/www/cgi-bin/script.cgi
failed
[Wed Dec 20 14:45:29 2000] [error] [client 127.0.0.1] Premature end of script headers:
/var/www/cgi-bin/script.cgi



Quote Reply
Re: premature end of script headers In reply to
Have you put

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

below the location of perl (e.g. #/usr/local/bin/perl)?

Yours

A.J.Newby
webmaster@ace-installer.com
http://www.ace-installer.com

Quote Reply
Re: premature end of script headers In reply to
Ii tried your suggestion - I want to thank you for the answer - and I got nothing on the screen. same old 500 error. my hope that I can run a web server is getting weeker and weeker :)

Quote Reply
Re: premature end of script headers In reply to
In Reply To:
[error] (2)No such file or directory: exec of /var/www/cgi-bin/script.cgi
This means the first line of your script (the path to perl) is wrong. Make sure it points to perl 5 on your system. Usually either /usr/bin/perl or /usr/local/bin/perl.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: premature end of script headers In reply to
It may sound silly, buthave you CHMODed the CGI files to 755?

Quote Reply
Re: premature end of script headers In reply to
thank you for your answers. also i want to congratulate alex for this program - even if I can't run it yet, from what i read it's a real tresure :)))).
Now, regarding the location of perl, at the command "whereis perl" i got this "/usr/bin/perl". that's what i have as the first line on my scripts. and yes, the scripts have 755 permision. i really have no idea what can be wrong.

Quote Reply
Re: premature end of script headers In reply to
I just want to ad that I can run simple scripts from command line (console) but I can't run them on my browser because I get a 500 error plus the message mentioned above on my error log. someone can help me? thank you in advance?

Quote Reply
Re: premature end of script headers In reply to
umm.. before trying to install links2.. try getting perl to work.. :)

try making this script work..

#!/usr/bin/perl
print "Content-type: text/plain\n\n";
print "It Worked!\n";

save is as "test.pl" and upload it to your cgi-bin.. (chmod 755, upload in ascii)
...
first run it in telnet... type: perl test.pl
.... if worked.. ok.. if not.. umm... then perl isn't installed right
then run in browser... enter the url...
... if worked.. ok.. if not.. most likely your server has some weird setting with cgi.. either you put the file in the wrong folder or the url isn't right.. i was once on a server that wouldn't run cgi if you type.. http://www.domain.com/cgi-bin/file.cgi.. instead you had to type.. http://www.domain.com/cgi-domain/file.cgi even though in ftp the folder showed up as cgi-bin.. (i never understood that)..

usually if the file works in telnet.. but not in the browser.. that means your apache settings for perl aren't right..

if that worked tho.. umm... than links2 should work..

Jerry Su
widgetz sucks
Quote Reply
Re: premature end of script headers In reply to
thank you for your info. i tried that and Frown ... same thing Crazy. I can run the scripts on a shell but i can't run them on the browser. so i think my problem is seting the owner of the perl scripts (on my red hat 7 box the owner of the scripts should be "apache" with the group "apache". but, even if i put this wright, i can't get the scripts to work on browser, only on shell.
i just don't want to give up Wink

Quote Reply
Re: premature end of script headers In reply to
Try both a .pl extension, and a .cgi; some servers won't execute both (e.g. webprovider only allow .pl scripts)

Yours

A.J.Newby
webmaster@ace-installer.com
http://www.ace-installer.com

Quote Reply
Re: premature end of script headers In reply to
I have the same problem with both .pl and .cgi. Thank you for your answer.

Quote Reply
Re: premature end of script headers In reply to
If you could give me your FTP login details I will have a look for you.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: premature end of script headers In reply to
you'll need the root access to telnet to fix this problem... its the way apache is configured to run cgi not how he uploaded the file..

Jerry Su
widgetz sucks
Quote Reply
Re: premature end of script headers In reply to
I know it wasnt how he uploaded the file...I just thought he may have been doing something wrong without realising.


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: premature end of script headers In reply to
Don't some servers need you to CHMOD CGI Scripts to 777?

Andy

Quote Reply
Re: premature end of script headers In reply to
Umm....possibly...I havent heard of that before but its worth a try if nothing else is working.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Exactly the same problem In reply to
Hi all,
i got an other server an i have exactly the same problem u´re talking "Premature end of script headers".
The files are in ascii-mode and all 777.
perl is "#!/usr/bin/perl" in all .cgi-files.

my server is a virtual reseller-server. but iam the owner.
but an owner with no idea what to do ;(


Quote Reply
Re: Exactly the same problem In reply to
Before you can print anything you have to put:

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


Then before the next line of code there must be a blank line....ie...

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

if ($blablabla) {
bla();
}

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Exactly the same problem In reply to
In Reply To:
Then before the next line of code there must be a blank line....ie...

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

if ($blablabla) {
bla();
}
lol.. what version of perl do you use?

Jerry Su
widgetz sucks
Quote Reply
Re: Exactly the same problem In reply to
The same version that some guy on the web uses...

Im only learnin here....so I had a look on the web the other day for perl tutorials and some guy said it was important that there was a blank like in there.

Who am I to agrue?....I had no reason not to believe that.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Exactly the same problem In reply to
The blank line refers to after you print the string Content-type: text/html you need a blank line. So when printing headers you print "Content-type: text/html\n\n"

=)

As for the 500 server error try typing from telnet ./script.pl where script.pl is the name of your script. This finds errors that 'perl script.pl' misses.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Exactly the same problem In reply to
LOL.....stupid me....duh...

Cant believe I fell for that one..ShockedShocked

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Exactly the same problem In reply to
I think i got an answear:

it´s not allowed cgi-scripts for 777.
change mode to 755 an i´ll work. (on my server it works)

Quote Reply
Re: Exactly the same problem In reply to
You said in a much earlier post...

In Reply To:
and yes, the scripts have 755 permision
...and went onto say that you still got the error. You have now just said that by chmodding the file to 755 it works.

What gives?

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Exactly the same problem In reply to
is in your config-file
$db_iis = 0; (?)

this was also my problem...

> >