davidlt77 has asked for the wisdom of the Perl Monks concerning the following question:

I've installed AM Lite on an HP-UX 11.0 system running Apache 2 with PERL 5.8.0. When accessing http://root/cgi-bin/amadmin.pl, I get the following error:

Server error!
Error message:
Premature end of script headers: /opt/apache2/lib/htdocs/cgi-bin/amadmin.pl
If you think this is a server error, please contact the webmaster Error 500

I've done the following:

1. Validated that the path to perl is correct.
2. Ensured permissions on the cgi-bin dir and the file are loose enough (755).
3. Run the script from the command line to ensure the PERL binary is accessible by the user www.
4. I've done some other things, but my brain is fried, as I've been looking at this problem most of the day!

Following are the errors in the Apache error_log:

syntax error in file amadmin.pl at line 221, next 2 tokens "grep {" syntax error in file amadmin.pl at line 224, next 2 tokens "@file)" syntax error in file amadmin.pl at line 241, next token "}" syntax error in file amadmin.pl at line 252, next token "}" syntax error in file amadmin.pl at line 275, next token "}" syntax error in file amadmin.pl at line 327, next token "}" syntax error in file amadmin.pl at line 381, next token "}" syntax error in file amadmin.pl at line 389, next 2 tokens "grep {" syntax error in file amadmin.pl at line 479, next token "}" syntax error in file amadmin.pl at line 485, next 2 tokens "grep {" amadmin.pl has too many errors. [Wed Jan 14 15:28:14 2004] [error] [client 172.28.6.107] Premature end + of script headers: /opt/apache2/lib/htdocs/cgi-bin/amadmin.pl
Since the file is a bit large to post, please see http://www.angelfire.com/fl5/davidlt77/index.html.

Thank you!

Dave

20040115 Edit by Corion: Put code tags around error message

Replies are listed 'Best First'.
Re: CGI: Premature end of script headers
by Abigail-II (Bishop) on Jan 15, 2004 at 13:44 UTC
    syntax error in file %s at line %d, next 2 tokens "%s" (F) This error is likely to occur if you run a perl5 script through a perl4 interpreter, especially if the next 2 tokens are "use strict" or "my $var" or "our $var".

    Abigail

Re: CGI: Premature end of script headers
by Joost (Canon) on Jan 15, 2004 at 13:54 UTC
    That script is SO badly written that your errors could be comming from anywhere. Here's the output from the perl compiler on the command line (after I removed all the "==>" stuff):
    perl -c test.pl Useless use of push with no values at test.pl line 224. Unquoted string "aa" may clash with future reserved word at test.pl li +ne 289. Unquoted string "details" may clash with future reserved word at test. +pl line 48 9. Unquoted string "deny" may clash with future reserved word at test.pl +line 599. Unquoted string "approve" may clash with future reserved word at test. +pl line 64 8. Unquoted string "aa" may clash with future reserved word at test.pl li +ne 674. Unquoted string "aa" may clash with future reserved word at test.pl li +ne 770. Unquoted string "adelete" may clash with future reserved word at test. +pl line 10 11. Unquoted string "adelete" may clash with future reserved word at test. +pl line 10 56. Unquoted string "aa" may clash with future reserved word at test.pl li +ne 1250. Unquoted string "fname" may clash with future reserved word at test.pl + line 1351 . Unquoted string "lname" may clash with future reserved word at test.pl + line 1360 . Unquoted string "aa" may clash with future reserved word at test.pl li +ne 1599. Unquoted string "aa" may clash with future reserved word at test.pl li +ne 1630. Name "main::bodyspec" used only once: possible typo at test.pl line 14 +72. Name "main::month" used only once: possible typo at test.pl line 182. Name "main::date2" used only once: possible typo at test.pl line 181. test.pl syntax OK
    I would suggest looking for something better (what the h*ll is this thing supposed to do anyway?)

    Joost.

      If shareware code of this company is any indication of the quality of their Pro products' code I would definitely recommend against buying from them.

      Arjen

      I appreciate the quick response from everyone. Thanks for taking the time to look at the code.

      Joost, the code is part of a package to manage accounts and passwords to a Web site. It's freeware from http://www.siteinteractive.com/acctlite/. Maybe I'll take your advice and search for something else!

      Thnx,

      Dave
        Their is a package I looked at and one of my juniors used for a client called BURP (Basic User Registration Package). It can be found at this location.

        But be warned - it is mod_perl based. However it was a snap to install, the documentation is very clear and the code was very well written IIRC.

        jdtoronto

Re: CGI: Premature end of script headers
by Roger (Parson) on Jan 15, 2004 at 13:51 UTC
    Looking at your code below, all you want to do is to find out how many *.infotmp* files there are under $memberinfo directory.
    opendir (DIR, "$memberinfo"); @file = grep { /.infotmp/ } readdir(DIR); close (DIR); $new_files = push(@file);

    You could replace all that with a one-liner:
    $new_files = @{[<$memberinfo/*\.infotmp*>]};