uShop English (U.S.) for 179!

uStorekeeper English (U.S.) for 149!

 Tech Support
       Support Policy
       Knowledge Base
       Reference Sites
       Software Piracy
       Legal Notices
       Privacy Policy
       Reseller Info
       Contact Us
       Site Map
"Premature end of script headers" Message

Knowledge Base Lobby : uDirectory Support Conference : General uDirectory Troubleshooting
Nov-21-17 06:16 PM EST
Original Message
"Premature end of script headers" Message
Author Moderator on 09-27-1999 at 18:23 (EST)
I bought the Deluxe uDirectory and try to install it but get error when excecute it as http://www.my_directoy/ I look at the server's error.log and it says "Premature end of script headers: /cgi-bin/" Do you have any idea what is going on? I double check all the variables and they look correct. I also double the permission on both cgi and listing directories. I also try to rename the script to udirectory.cgi but no help. I know my cgi-bin directory work because I have a form handler script in there too and it works. My server is Linux base running Apache.

Table Of Contents
  Premature end of script headers Moderator, 1999-09-27 18:26:06 (1)
            "premature end of script headers" part deux Jona Decker, 2001-11-30 16:37:44 (2)
                 premature end of... Jona Decker, 2001-11-30 18:35:47 (3)
                      RE: premature end of... Joseph Pishgar, 2001-12-03 14:06:45 (4)
                      RE: premature end of... Bill Weiner, 2001-12-04 07:48:27 (5)

Messages In This Discussion
         1. Premature end of script headers
        Author Moderator on 09-27-1999 at 18:26 (EST)
In regard to the problem you are seeing:

1) First, just to be sure (although this is probably not the problem), make sure that the script was transferred to your server in ASCII or TEXT mode (as opposed to BINARY or RAW mode). Transferring it in BINARY or RAW mode could cause that be sure it was transferred in ASCII or TEXT mode.

2) What version of Perl are you using? We wrote uDirectory to be compatible (in theory) with both Perl 4 and Perl 5, however, we have seen that some people using Perl 5 (particularly Perl 5.00502) will get that "Premature end of script headers" (See the CASE DESCRIPTION below). So if you have an option to use Perl 4, then go with that.


As we often help people get the script setup on their server, we did ran across this once. The person gave us two paths to Perl on their server:


When using #!/usr/local/bin/perl5.00502 for the path to Perl (the first line of the script), we got the following error:

Internal Server Error

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

Please contact the server administrator, and inform them of the time the error occurred, and
anything you might have done that may have caused the error.

There was also some additional information available about the error:
[Sun Jan 24 07:38:41 1999] access to /u/web/bestb7/cgi-local/ failed for, reason: Premature end of script headers

Then when we changed the path to #!/usr/local/bin/perl, and everything worked fine.

I'm not exactly sure what type of server they were using (since we just FTPed to the server/account that they gave us), but changing that path (I'm guessing to an older version of Perl) worked. Again, we have only ran into this once and the uDirectory CGI script should have worked with Perl 5.00502 - but I don't know why we got the error.

In anycase, double-check the path to perl that you are using.

                 2. "premature end of script headers" part deux
                Author Jona Decker on 11-30-2001 at 16:37 (EST)
I am having a similar problem...testing uDirectory Personal before buying uDirectory Business.

I'm able to login, and to access the "Add" screen. However, when I try to add a user, I get the ubiquitous Internal Server Error with "premature end of script headers" as the error, which isn't very helpful.

I've run it from the command line, which *was* a little more helpful. The error message I get there is:

perl udirectory.cgi
parse error in file udirectory.cgi at line 707, next 2 tokens "create_main_form("
Execution of udirectory.cgi aborted due to compilation errors.

Line 707 is:

create_main_form("The listing " . $original_lastname . ", " . $original_firstname . " was not found.");

(Apologies for any browser wrap that may occur. It's all one line in the script as written)

I've seen this error before in relationship to Perl versions, but going *up* has always helped, not hurt. I've used the path to both perl4 and perl5 on my system, and both generate this error.

Any ideas?


                         3. premature end of...
                        Author Jona Decker on 11-30-2001 at 18:35 (EST)
I disabled taint in perl 5 and the script is working. (Current host requires running scripts with taint checking...but that will be a non-issue soon). However, I still see the token errors when I run perl from the command line, and being the retentive sort, don't like it. What can I do to make the script "legal" and what kind of server impacts result from running it the way it is?

                                 4. RE: premature end of...
                                Author Joseph Pishgar on 12-03-2001 at 14:06 (EST)
Hello Jona,

Taint should definitely be disabled when running uDirectory. Additionally, any other perl path modifiers should be turned off (removed from the first magical line of the script) before uploading and CHMODing the script if possible. Recheck the path to perl, and paths to the listings directory are correct (and chmoded 777).

Try that, and see if the errors continue to persist.

Joseph Pishgar
Microburst Technologies, Inc.
                                 5. RE: premature end of...
                                Author Bill Weiner on 12-04-2001 at 07:48 (EST)
Actually, "taint" should not be causing a problem with the CGI script.

Looking at your original error message:

parse error in file udirectory.cgi at line 707, next 2 tokens "create_main_form("......

Line 707 in the script does call the "create_main_form" subroutine... however, it appears that line is missing an ampersand ( & ) in front of the function name. That is, in Perl, most function calls "should" have an ampersand directly before the function name. I say "should" because it is not really required... however, maybe having "taint" enabled does cause the ampersand to be required. (Note that all our other calls to "create_main_form" do have an ampersand in front of it.... it's just missing on the call in line 707 for some reason.)

Anyway, in short, try modifying line 707 in the udirectory_personal script such that the ampersand is before the "create_main_form" call:

STEP 1: Make a backup of your current script... just in case.

STEP 2: Open your "" script with any text editor such as WordPad.

STEP 3: Locate line 707 in the script, which starts with the following:

create_main_form("The listing

STEP 4: Add an ampersand in front of that line, like this:

&create_main_form("The listing

STEP 5: Save the file.... as TEXT if your editor asks... and try it out!

© 2003 Microburst Technologies, Inc.