You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by "Thomas E. Dukes" <ed...@palmetto.dnsalias.net> on 2003/04/09 23:27:31 UTC

[users@httpd] .cgi/apache problems

H E L P !!

I'm getting the following error trying to run a .cgi script.  I have set
permissions to 755 but can't get it to run.  I am currently running this
script on a hosted website under RH 7.3.  I am trying to move my site to
my local home-network running as a virtual host under RH 8.0 and apache
2.0. I don't think this is a perl problem as I have a test.cgi that
works.

[Tue Apr 08 19:57:32 2003] [error] [client 10.10.0.2] Premature end of
script headers: classifieds.cgi

I have read the FAQ about premature end of script and believe it may be
in my virtual host setup.  I am not an "IT" person so  a lot of this
over my head.   I'd really appreciate some help.  I worked on this all
last night and now I'm brain dead.

Anyone know what else I can check?

This is my virtual host setup:
<VirtualHost *>
DocumentRoot /home/www.palmettoshopper.com/html/
ServerName www.palmettoshopper.com
ServerAdmin admin@palmettoshopper.com
ScriptAlias /cgi-bin/ /home/www.palmettoshopper.com/html/cgi-bin/
ErrorLog /home/www.palmettoshopper.com/logs/error_log
CustomLog /home/www.palmettoshopper.com/logs/access_log "%h %l %u %t
\"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" LogFormat "%h %l %u %t
\"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined LogFormat "%h
%l %u %t \"%r\" %>s %b" common LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent <Directory
"/home/www.palmettoshopper.com/html/">
  AllowOverride all
</Directory>
<Directory "/home/www.palmettoshopper.com/cgi-bin/">
  Options +ExecCGI
</Directory>
ServerAlias palmettoshopper.com
</VirtualHost>

Palmetto Shopper 
http://www.palmettoshopper.com
Serving all of South Carolina and beyond!



---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .cgi/apache problems: SOLVED

Posted by "Thomas E. Dukes" <ed...@palmetto.dnsalias.net>.
I found the problem.  Here's what it was:

#!/usr/bin/perl
# blah
# blah
# blah
unless ($noheader eq "on") {
print "Content-type: text/html\n\n";
}

I commented the the second and third line leaving only:

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

I'm not a perl programmer and don't know why that was like that, but its
working.  :-)

Thanks, everyone!!!!


Palmetto Shopper 
http://www.palmettoshopper.com
Serving all of South Carolina and beyond!



> -----Original Message-----
> From: Joshua Slive [mailto:joshua@slive.ca] 
> Sent: Wednesday, April 09, 2003 7:04 PM
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] .cgi/apache problems
> 
> 
> 
> On Wed, 9 Apr 2003, Thomas E. Dukes wrote:
> 
> > The first line of the script is:
> >
> > #!/usr/bin/perl
> >
> 
> Yes, but is perl really located there?
> 
> If it is, try deleting that line and retyping it in a proper 
> unix editor. When you transfer between systems (especially 
> windows->unix) you can often mess up line endings, which 
> causes problems.
> 
> All the other issues are irrelvant until you can get the 
> script to start without typing "perl".
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project. See 
> <URL:http://httpd.apache.org/userslist.html> for more info. 
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .cgi/apache problems

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 9 Apr 2003, Thomas E. Dukes wrote:

> The first line of the script is:
>
> #!/usr/bin/perl
>

Yes, but is perl really located there?

If it is, try deleting that line and retyping it in a proper unix editor.
When you transfer between systems (especially windows->unix) you can often
mess up line endings, which causes problems.

All the other issues are irrelvant until you can get the script to start
without typing "perl".

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .cgi/apache problems

Posted by "Thomas E. Dukes" <ed...@palmetto.dnsalias.net>.
The first line of the script is:

#!/usr/bin/perl

Also, I did get Content-Type: text/html as the first line of output,
then all that EULA crap.

As I said previously, its running fine on my hosted site running RedHat
7.3 and apache 1.3.x.  I don't get it
.

In my virtual host statement, I have:
ScriptAlias /cgi-bin/ /home/www.palmettoshopper.com/html/cgi-bin/

But classifieds.cgi is in a subdirectory below that so it would be:
/home/www.palmettoshopper.com/html/cgi-bin/classifieds/classifieds.cgi

This is the way the install manual recommends.  Does that make a
difference?

TIA

> That needs to be fixed.  Apache doesn't invoke "perl 
> classifieds.cgi", it simply invokes the script directly.  
> Most likely, the path on the first line of the script needs 
> to be adjusted to the true location of perl.
> 
> > If I run perl classifieds.cgi, it prints out a lot of text 
> which looks 
> > like the EULA, a blank line, the </textarea><p>, blank line and the 
> > </FORM> with some html code.
> 
> Uhhh... I hope the first thing you saw was
> Content-Type: text/html
> followed by a blank line.  Otherwise, it won't work even when 
> perl gets invoked.
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project. See 
> <URL:http://httpd.apache.org/userslist.html> for more info. 
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .cgi/apache problems

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 9 Apr 2003, Thomas E. Dukes wrote:

> OK,
>
> If I run ./classifieds.cgi from the directory, I get bad intrepreter: No
> such file or directory.

That needs to be fixed.  Apache doesn't invoke "perl classifieds.cgi", it
simply invokes the script directly.  Most likely, the path on the first
line of the script needs to be adjusted to the true location of perl.

> If I run perl classifieds.cgi, it prints out a lot of text which looks
> like the EULA, a blank line, the </textarea><p>, blank line and the
> </FORM> with some html code.

Uhhh... I hope the first thing you saw was
Content-Type: text/html
followed by a blank line.  Otherwise, it won't work even when perl gets
invoked.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


RE: [users@httpd] .cgi/apache problems

Posted by "Thomas E. Dukes" <ed...@palmetto.dnsalias.net>.
OK,

If I run ./classifieds.cgi from the directory, I get bad intrepreter: No
such file or directory.

If I run perl classifieds.cgi, it prints out a lot of text which looks
like the EULA, a blank line, the </textarea><p>, blank line and the
</FORM> with some html code.

Palmetto Shopper 
http://www.palmettoshopper.com
Serving all of South Carolina and beyond!



> -----Original Message-----
> From: Joshua Slive [mailto:joshua@slive.ca] 
> Sent: Wednesday, April 09, 2003 5:33 PM
> To: users@httpd.apache.org
> Subject: Re: [users@httpd] .cgi/apache problems
> 
> 
> 
> On Wed, 9 Apr 2003, Thomas E. Dukes wrote:
> > [Tue Apr 08 19:57:32 2003] [error] [client 10.10.0.2] 
> Premature end of 
> > script headers: classifieds.cgi
> >
> > I have read the FAQ about premature end of script and 
> believe it may 
> > be in my virtual host setup.
> 
> That is unlikely.  The error usually means that apache tried 
> to execute the cgi script, but the script died before sending 
> proper http headers. Start by trying the following: cd 
> /home/www.palmettoshopper.com/html/cgi-bin/
> ./classifieds.cgi
> 
> Do you get proper HTTP headers from your script followed by a 
> blank line? If not, you need to fix your script.
> 
> Joshua.
> 
> ---------------------------------------------------------------------
> The official User-To-User support forum of the Apache HTTP 
> Server Project. See 
> <URL:http://httpd.apache.org/userslist.html> for more info. 
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
>    "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
> 


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] .cgi/apache problems

Posted by Joshua Slive <jo...@slive.ca>.
On Wed, 9 Apr 2003, Thomas E. Dukes wrote:
> [Tue Apr 08 19:57:32 2003] [error] [client 10.10.0.2] Premature end of
> script headers: classifieds.cgi
>
> I have read the FAQ about premature end of script and believe it may be
> in my virtual host setup.

That is unlikely.  The error usually means that apache tried to execute
the cgi script, but the script died before sending proper http headers.
Start by trying the following:
cd /home/www.palmettoshopper.com/html/cgi-bin/
./classifieds.cgi

Do you get proper HTTP headers from your script followed by a blank line?
If not, you need to fix your script.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org