in reply to Re: a classic : 'Premature end of script headers' problem
in thread a classic : 'Premature end of script headers' problem

What should they be? I'm just learning about apache permissions. This isn't a hosting account. These are my own dedicated servers. I am root (but I still do have tech support).

I learn more and more about less and less until eventually I know everything about nothing.
  • Comment on Re^2: a classic : 'Premature end of script headers' problem

Replies are listed 'Best First'.
Re^3: a classic : 'Premature end of script headers' problem
by Joost (Canon) on Sep 19, 2007 at 18:36 UTC
    the script should be executable for the webserver. But, AFAIK if isn't, you won't get that error.

    also: when you get the "premature end of headers" error, the webserver's error log can contain additional useful information (like what is received when it expects the header - generally the error is triggered by code that sends out messages/content before/while sending the header block)

    update: you should never use &subname; without parentheses to call a subroutine unless you know why that's a special case, and if you're using parentheses it's always safe to leave off the &, so IMO it's generally a good habit leave off the & and use parentheses where it makes sense, like subname()

      The error log for my server just gives
      [Wed Sep 19 13:42:19 2007] [error] [client xxx.xxx.122.100] Premature end of script headers: consent.cgi, referer: http://mysite.com/ase-workkeys/employerconsent.html
      over and over again.

      As for the subroutine calling, I used to call them with the () and no &, but someone told me that was unnecessary if the subroutine did not return any values. What is the danger? I am asking seriously. Thanks.


      I learn more and more about less and less until eventually I know everything about nothing.
        The danger is that calling a sub as &subname; (with an ampersand, without parentheses) will pass on the current subroutine's @_ argument array. Which is almost never what you want to do.

        Using both parentheses and & sign is the same as just parentheses, and you can usually get away without parentheses too, provided the subroutine is defined before the call.

        did you mistakingly change ownership to root? for example, deleted and recreated consent.cgi? Also, is consent.cgi chmod 0755 ? do ls -lha /your/path/to/consent.cgi
Re^3: a classic : 'Premature end of script headers' problem
by leocharre (Priest) on Sep 19, 2007 at 18:39 UTC

    oh wow.. ok .. you've got it easy on one hand because you have full access.. and hard on another because you have full access.

    do this instead.. vim /usr/bin/debughttp (as root)

    #!/bin/sh # this is just an example #tail -f /var/log/httpd/error_log tail -f /var/log/httpd/ssl_error_log | sed 's/^.\+0.41\]\|\, referer.\ ++\.cgi\|\?rm=\w\+//g' # or just # tail -f /var/log/httpd/error_log
    (you know how to set perms on that? chmod 0700, just you everything, everyone else nothing)

    Open a terminal and # debughttp forget the CGI::Carp 'fatalsToBrowser' crap.. get rid of all that, get rid of the open(STDERR, '>>' .. all that.

    Make sure you have the right path to your httpd error log

    call the script from your browser and enjoy the wonder that is POSIX.

      Ok, wow. Yeah, I may have root, but I don't understand any of that, so I'm not going to run off and put that on my server until I can spend sometime trying to figure out what tail does.
      In Apache that user is set up to have the error log at /home/account/logs, is this not the httpd error log?
      Thanks.

      UPDATE: In the /var/log/httpd/suexec.log, I found this:

      [2007-09-19 14:00:05]: uid: (506/devpreview) gid: (506/506) cmd: conse +nt.cgi [2007-09-19 14:00:05]: command not in docroot (/home/acccount/cgi-bin/ +asewk/consent.cgi)

      I assume this is a user account issue then and not my actual perl script?

      I learn more and more about less and less until eventually I know everything about nothing.

        If your answer to what I posted is '..trying to figure out what tail does..' Maybe you should not have root access on a server that serves outsite an intranet.

        You should know to # man tail

        You should really learn unix before you have that kind of control over a server.

        If you know what you're doing, you can secure a machine like that to be a fortress. If you don't- and you have root.. you can blow yourself up- maybe even take some people with you.

        I don't think there's any way I can prevent as coming accross as patronizing. I am sorry for that. I do not mean disrespect.

        I am sure you can learn this up and down and left and right. But until you do- I must stress - don't open that thing to accept outside requests- via the internet.

        A week or two of reading up could do a lot for you.