Premature end of script $#!

They have: 21 posts

Joined: Sep 1999

Hi, I am running into a very frustating problem. I was running a lot of complicated perl-cgi scripts and they were all working perfectly fine. I had to move to a new server which I set up the other day (Apache 1.3.9).

I moved all the scripts over and then tried them. They all give me 500 internal error. I checked the log file and it says "premature end of script header"!! However, when I tried executing the scripts from the shell, they are all okay, no error and anything.

I checked:
YES 1. perl path (correct)
YES 2. Correct header print ("Content-type: text/html")
YES 3. There is a line after the header print.
YES 4. Perl is 5.00503

I even tried a very easy script and it is also giving me the same error.
#!/usr/bin/perl

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

Again, this runs fine from the command line with no error, but via the web, it's 500 internal error because of "premature end of script"

I do not think this is the web server problem.(?)
Please help. Any advice is greatly appreciated. Thanks.

They have: 161 posts

Joined: Dec 1999

That which I say three times is true:

Check the server's error log!

Check the server's error log!

Check the server's error log!

There should be a better explanation as to why the script didn't return headers correctly in the error log.

------------------
--
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve

They have: 21 posts

Joined: Sep 1999

Yes it is ascii format Like I mentioned, it does run fine on the shell command line. I set up the server myself and the httpd.conf file is really starightforward/ and simple! I was going to add a lot more stuff in the file and thought I would test a script first.

Everything else runs just great as far as my server. Virtual servers' log, root, etc..

They have: 21 posts

Joined: Sep 1999

[Wed Jan 5 15:08:43 2000] [notice] Apache/1.3.9 (Unix) (Red Hat/Linux) configured -- resuming normal operations
[Wed Jan 5 15:08:43 2000] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Wed Jan 5 15:09:13 2000] [error] (2)No such file or directory: exec of /home/test/cgi-bin/test.pl failed
[Wed Jan 5 15:09:13 2000] [error] [client 127.0.0.1] Premature end of script headers: /home/test/cgi-bin/test.pl

By looking at the error log, I do not quite get it why it says no such file and directory and then it goes on with a premature end message, which means that it executed the script but failed. The directory cgi-bin does exist and it is configured to be executable correctly. The server root dir is /home/test/www. The script is an easy (just for testing purpose) one.

#!/usr/bin/perl

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

print "Hello";

Any idea?
(Patrick, I would not mind posting the config file but I think the log might trigger some "I know what it is" advices?

Thanks again!

[This message has been edited by vbedceo (edited 06 January 2000).]

They have: 21 posts

Joined: Sep 1999

Yes there is! That's why I am so frustating. Is there other anything tiny enough that I just am just not seeing? Help. I am sure it is not a big problem. I have set up quite a few # of servers but never got into this problem. I do not see the attachment option, otherwise I would be attaching my conf file.

They have: 12 posts

Joined: Dec 1999

I encounter this kind of problem whenever I edit the script in windows' notepad which inserts carriage returns. What you can do is download EditPad free from http://www.jgsoft.com and then open the script and File/Export the file as Unix (LF Only), this removes the CR from the script.

Hope that helps.

------------------
Webhosting Free Reseller Program: Earn $100 plus 25% per month.

They have: 21 posts

Joined: Sep 1999

I created a new file for a very easy script using vi on the machine so it should be okay. But the same error comes up.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.