Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Premature end of script headers ERROR ! 1

Status
Not open for further replies.

zick79

Technical User
May 19, 2003
40
CA
hI i AM getting this what is in my title error every time i run hello.cgi. Check at drwx--x--x 8 root root 4096 Feb 4 19:54 ./
drwxr-xr-x 8 root root 4096 Jan 27 19:38 ../
-rw-rw-r-- 1 root root 24 Jan 27 19:38 .bash_logout
-rw-rw-r-- 1 root root 191 Jan 27 19:38 .bash_profile
-rw-rw-r-- 1 root root 124 Jan 27 19:38 .bashrc
drwxr-xr-x 2 root root 4096 Feb 4 19:56 bin/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 etc/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 lib/
drwxrwxrwx 2 root root 4096 Feb 4 19:42 logs/
-rw-rw-r-- 1 root root 141 Jan 27 19:38 .mailcap
drwxr-xr-x 6 root root 4096 Feb 4 11:46 public_html/
drwxrwxr-x 2 root root 4096 Jan 27 19:38 tmp/
-rwxrwxr-x 1 root root 179 Nov 30 19:17 welcome.msg*
[root@Samba-netbios jurek]# chgrp -R jurek public_html
[root@Samba-netbios jurek]# ls -la
total 52
drwx--x--x 8 root root 4096 Feb 4 19:54 ./
drwxr-xr-x 8 root root 4096 Jan 27 19:38 ../
-rw-rw-r-- 1 root root 24 Jan 27 19:38 .bash_logout
-rw-rw-r-- 1 root root 191 Jan 27 19:38 .bash_profile
-rw-rw-r-- 1 root root 124 Jan 27 19:38 .bashrc
drwxr-xr-x 2 root root 4096 Feb 4 19:56 bin/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 etc/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 lib/
drwxrwxrwx 2 root root 4096 Feb 4 19:42 logs/
-rw-rw-r-- 1 root root 141 Jan 27 19:38 .mailcap
drwxr-xr-x 6 root jurek 4096 Feb 4 11:46 public_html/
drwxrwxr-x 2 root root 4096 Jan 27 19:38 tmp/
-rwxrwxr-x 1 root root 179 Nov 30 19:17 welcome.msg*
[root@Samba-netbios jurek]# chmod -R 755 public_html
[root@Samba-netbios jurek]# ls -la
total 52
drwx--x--x 8 root root 4096 Feb 4 19:54 ./
drwxr-xr-x 8 root root 4096 Jan 27 19:38 ../
-rw-rw-r-- 1 root root 24 Jan 27 19:38 .bash_logout
-rw-rw-r-- 1 root root 191 Jan 27 19:38 .bash_profile
-rw-rw-r-- 1 root root 124 Jan 27 19:38 .bashrc
drwxr-xr-x 2 root root 4096 Feb 4 19:56 bin/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 etc/
drwxrwxr-x 2 root root 4096 Jan 27 23:55 lib/
drwxrwxrwx 2 root root 4096 Feb 4 19:42 logs/

































[Wed Feb 04 19:06:48 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:10:43 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi

































[Wed Feb 04 19:06:48 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:10:43 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:10:45 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:25:09 2004] [error] [client 192.168.0.2] File does not exist: /home/jurek/public_html/cgi-bin
[Wed Feb 04 19:25:29 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
~
~
b0VIM 6.1^@^@^@^@^P^@^@y~M!@V±^B^@÷v^@^@root^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@Samba-netbios^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@/home/jurek/logs/error_log^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^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@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^[Wed Feb 04 19:06:48 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:10:43 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi
[Wed Feb 04 19:10:45 2004] [error] [client 192.168.0.2] Premature end of script headers: hello.cgi

~
~
~
~
~
~
~
~


################# IP-based Virtual Hosts
#<VirtualHost 192.168.2.100>
#User jmdault
#Group jmdault
#DocumentRoot /home/jmdault/public_html
#ServerName test2.com
#Setenv VLOG /home/jmdault/logs
#ErrorLogs /home/jmdault/test2-error_log
#RewriteEngine On
#RewriteOptions inherit
#</VirtualHost>

################# Named VirtualHosts
#!/usr/local/bin/perl -w
# SSLOptions +StdEnvVars
# </Directory>



################# Vhosts.conf
################# Vhosts.conf
################# Vhosts.conf
#This is where we store the VirtualHosts configuration.
#
#Since Apache 1.3.19, we modified the setup to include some nice tricks:
#
#- We added the User and Group directives so VirtualHosts now work with
# suexec directive. If set, Apache will run all cgi scripts under that
# user and group (provided the uid and gid are > 100 for security). The
# directories and cgi files *must* belong to that user/group for the
# feature to work
#- We added the Setenv VLOG directive. This works in conjunction with
# the CustomLog in common.conf. When Setenv VLOG is set, apache will
# create a /var/log/httpd/VLOG-YYYY-MM-<ServerName>.log instead of logging
# to access_log. Use this instead of defining a special logfile for
# each vhost, otherwise you eat up file descriptors.
#- You can also specify a path for the VLOG for each Vhost, for example,
# to place the logs in each user's directory. However, if you want to
# use the file for accounting, place it in a directory owned by root,
# otherwise the user will be able to erase it.
#- I suggest only including the ErrorLog *only* if the vhost will use
# cgi scripts. Again, it saves file descriptors!
#- We added the Rewrite directives so vhosts will work with the
# PERLPROXIED configuration


################# IP-based Virtual Hosts
#<VirtualHost 192.168.2.100>
#User jmdault
#Group jmdault
#DocumentRoot /home/jmdault/public_html
#ServerName test2.com
#Setenv VLOG /home/jmdault/logs
#ErrorLogs /home/jmdault/test2-error_log
#RewriteEngine On
#RewriteOptions inherit
#</VirtualHost>

################# Named VirtualHosts
#NameVirtualHost 111.222.33.44
#<VirtualHost 111.222.33.44>
#ServerName #ServerPath /domain
#DocumentRoot /web/domain
#</VirtualHost>


# Add this if you want to use CGI scripts
# ScriptAlias /cgi-bin/ &quot;/opt/zope/cgi-bin/&quot;
# <Directory /opt/zope/cgi-bin/>
# Options ExecCGI
# AddHandler cgi-script .cgi
# SSLOptions +StdEnvVars
# </Directory>




<VirtualHost *>
ServerName DocumentRoot /home/jurek/public_html
ServerAlias *.tomaszbaranowski.com
ErrorLog /home/jurek/logs/error_log

ScriptAlias /cgi-bin/ /home/jurek/bin/

<Directory &quot;/home/jurek/public_html&quot;>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

<Directory &quot;/home/jurek/bin&quot;>
AddHandler cgi-script .cgi
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


This is in my conf Apache. Permission is set and root is an owner in the jurek home dir exep the public_html.the resst is 755 like: bin etc lib etc.


Thanks for you help.
 
It looks like you have apache configured correctly. The problem seems to be with the script. The error message doesn't help much because all it means is that the server couldn't read the shebang for one reason or another. If the shebang is correct, then the problem may be with control characters like ^M. This usually happens when you download a file from Windows or a file that was zipped using winzip and then unzipped on a linux machine.
 
I guess that hello.cgi is a shell script... may be 'ls -l'?

1. I think apache will not allow you run shell scripts, not sure.. but I never be able to do it.

2. if this is possible, firsts line to show to the page is:

Content-type: text/html

so first 2 lines of your script should be:

#!/bin/sh
echo &quot;Content-type: text/html&quot;

... code here..

But I insists, I don't think you can run a shell script.

 
It is Perl Script and it still donesn't work. The same problem
 
your perl script should send somewhere after headersan empty lines (it'a about HTTP protocol).
So, a script should look like:

#!/usr/bin/perl
print &quot;Content-type: text/html&quot;;
# the empty line
print &quot;\n\n&quot;;

print &quot;CONTENT&quot;;
 
HI all

I just want to tell you ALL that &quot;predamarcel&quot; tek-tip member is the SMARTES MEN, I know if we talk about debugging my problem. My script works FINE, THX MAN YOU ROOOOOOOOOOOOOOOOCK. All the best. I thank you, it took me WEEEEEEKs and you solved it in SECENDS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Thx you alll for you contribution.

ALL the best to you all I LOVE THIS FORUM.
 
I gave 'm a star for ya - I know the buttons are kinda hard to find in this thread.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top