in reply to Re: Premature end of script headers
in thread Premature end of script headers

thank you for the reply.
I run the script command-line, and found no error.
perl -c -T /var/www/gestioip/install/index.cgi
/var/www/gestioip/install/index.cgi syntax OK

Replies are listed 'Best First'.
Re^3: Premature end of script headers
by choroba (Cardinal) on Sep 30, 2015 at 10:11 UTC
    -c doesn't run the script, it just compiles it. Try running it without the option and check the output as described in the previous post.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      perl -d -T /var/www/gestioip/install/index.cgi

      Loading DB routines from perl5db.pl version 1.33
      Editor support available.

      Enter h or `h h' for help, or `man perldebug' for more help.

      main::(/var/www/gestioip/install/index.cgi:27):
      27: my $lang;

      But...
      try to put a test.cgi script in www dir with this :

      #!/bin/sh
      echo "Content-type: text/plain"
      echo
      set

      It generates the same error in apache error.log
        Don't use -d unless you want to debug your script in the debugger.
        لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      perl -d -T /var/www/gestioip/install/index.cgi

      Loading DB routines from perl5db.pl version 1.33
      Editor support available.

      main::(/var/www/gestioip/install/index.cgi:27):
      27: my $lang;

      But.... I try to put a test.cgi script in www dir with this :

      #!/bin/sh
      echo "Content-type: text/plain"
      echo
      set

      It generates the same error in error.log
        It generates the same error in error.log

        Well done. You have successfully proven that the problem is not related to perl in any way.

Re^3: Premature end of script headers
by perlron (Pilgrim) on Sep 30, 2015 at 21:31 UTC
    Hi
    It would be ideal if you had updated your post with the /gestioip/install/index.cgi source code, though it is easy to find on the Gestioip page.

    Assuming (based on what you say in Re^4: Premature end of script headers line 27 in your source file) is reffering to the code below we can access from their site ,Its likely there is a config issue which is causing the script to die before it can return the Content-Type Header Tag.

    I feel you must now also look in the logfile called setup.log mentioned in the Gestioip install_guide pdf, for any clues about errors/issues in config or during setup.
    Also im not sure which apache log u are referring to is it the error log or access log ?
    eg: tail -n 5 /var/log/apache~~/error.log
    #!/usr/bin/perl -T -w use strict; #comments till line 27 my $lang; if ( $ENV{'QUERY_STRING'} ) { $ENV{'QUERY_STRING'} =~ /.*lang=(\w{2}).*/; $lang=$1; my $fut_time=gmtime(time()+365*24*3600)." GMT"; my $cookie = "GestioIPLang=$lang; path=/; expires=$fut_time; 0 +"; print "Set-Cookie: " . $cookie . "\n"; } elsif ( $ENV{'HTTP_COOKIE'} ) { $ENV{'HTTP_COOKIE'} =~ /.*GestioIPLang=(\w{2}).*/; $lang=$1; } if ( ! $lang ) { $lang=$ENV{HTTP_ACCEPT_LANGUAGE}; $lang =~ /(^\w{2}).*/; $lang = $1; } my $config; if ( $lang eq "es" ) { $config="./vars_es"; } elsif ( $lang eq "en" ) { $config="./vars_en"; } elsif ( $lang eq "de" ) { $config="./vars_de"; } else { $config="./vars_es"; } open(CONFIG,"<$config") or die "can't open $config: $!"; my %preferences; while (<CONFIG>) { chomp; s/#.*//; s/^\s+//; s/\s+$//; next unless length; my ($var, $value) = split(/\s*=\s*/, $_, 2); $preferences{$var} = $value; } close CONFIG; print <<EOF; Content-type: text/html\n <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML> <head><title>$preferences{title}</title>

    The Great Programmer is one who inspires others to code, not just one who writes great code