The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Premature end of header

Discussion in 'General Discussion' started by MarkB, Apr 20, 2003.

  1. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    One of my client's CGI scripts are not working.

    Files are uploaded in ASCII

    Files execute fine under shell

    Files are chmod'd to 755 (as is the cgi-bin directory)

    Error log output:

    [Sun Apr 20 06:34:39 2003] [error] [client 213.123.148.20] Premature end of script headers: /home/hell/public_html/cgi-bin/index.cgi

    suexec_log ouput:


    [2003-04-20 06:34:51]: info: (target/actual) uid: (hell/hell) gid: (hell/hell) cmd: index.cgi

    Any ideas? :confused:
     
  2. radhika

    radhika Active Member

    Joined:
    Jan 26, 2003
    Messages:
    39
    Likes Received:
    0
    Trophy Points:
    6
    This is the most worst 'Hey...I am here. Let me see what you can do for me' type error...I hate this 500 error.

    1. You checked any special modules are required by the script and installed on your server?

    2. If the ftp software set up to 'Autodetect', especially if your client using windows, files won't upload properly. So tell him to delete files and set his ftp software to 'ASCII' manually and try again.
     
  3. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    None of the ones I've been testing require any modules, and I've uploaded them myself too - and made sure they were in ASCII...
     
  4. X-Istencedotcom

    X-Istencedotcom Well-Known Member

    Joined:
    Apr 14, 2003
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    if you have SSH access, login and open a new document. Then copy and paste the stuff into the document, save and your done.

    I can do this with Secure Shell Client, so get that at http://ssh.com/ if you need.
     
  5. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Seems this is not just one client it's happening to. We only have a handfull of clients, most of which don't use cgi -- however, it's happening on any account trying to use cgi.

    This is on a fresh installation of CPanel on a FreeBSD server, if that helps...
     
  6. X-Istencedotcom

    X-Istencedotcom Well-Known Member

    Joined:
    Apr 14, 2003
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    It doesnt really matter. I dont believe that it matters, its cPanel and it has a lot of bugs, what can you expect.
     
  7. X-Istencedotcom

    X-Istencedotcom Well-Known Member

    Joined:
    Apr 14, 2003
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    i dont generally correct people in fear of getting flamed, but i tried and i got the same thing. I uploaded in ASCII mode, and created the script right there on the shell. Still happening, messing with chmod's didnt help.
     
  8. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    This is not a problem with files being uploaded in binary or ascii. I have double and triple checked this, and these files were brought over from a server backup done prior to the fresh install of cpanel - and they worked fine before that was done.

    I posted the error_log and suexec_log comments in the first post...

    Thanks for the reply :)
     
  9. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Nevermind, looks like it is solved.

    My client's document roots were in /home whereas my server docroot was in the default. I've made changes so both shared the same directory heirachy, and now scripts are running fine under suexec.

    Mark
     
  10. X-Istencedotcom

    X-Istencedotcom Well-Known Member

    Joined:
    Apr 14, 2003
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    Ah, that didnt work for me. Ill keep looking.
     
  11. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Gah -- the problem has returned, despite it working overnight... And nothing has changed as far as I know.

    *sigh*
     
  12. vishal

    vishal Well-Known Member

    Joined:
    Jan 28, 2003
    Messages:
    340
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    If the Problem is not Solved!!

    Hello,

    Here are some common care Tips that should be taken if u get the hell "Premature End of Script Headers".

    1. First and the Foremost Check the Shebang line #!/usr/path/to/perl ==> Valid.

    2. Check the Permissons 755 for .cgi and .pl files.

    3. Check the Files (i.e cat the files and see that u don't get any special characters at the end as it normally happens when u download the scripts from the Net.) take u'r scripts to a Simple Editor and re-upload them.

    4. Check the httpd.conf and u have the ScriptAlias /cgi-bin line (By default it exists) but make sure that it does.

    5. Normally when u execute the script the Browser shows "500- Internal Server errro" and the error_log says "Premature end of script header". This can also happen if u have any perl module missing. so to solve it just add these two line after the Shebang line.
    ###################################
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
    ###################################

    Then execute the script from the browser it will give out the exact error.

    6. Also be sure that the scrpit doesn't send any header's before the print "Content-type text/html...." line.


    Hope this Helps:)

    Regards,
     
  13. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    Thanks for the advice, but no difference was made :(

    I'm having my host take a look before taking it to the cpanel support team...
     
  14. vishal

    vishal Well-Known Member

    Joined:
    Jan 28, 2003
    Messages:
    340
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    That;s ok!!

    Hello,

    Need some info from u???

    ur WHM/Cpanel Version??
    What script are u using?

    What is displayed on the Browser when u execute the Script (Before and After Adding the Following lines)???
    ##############
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
    ##############

    Regards,
    :)
     
  15. X-Istencedotcom

    X-Istencedotcom Well-Known Member

    Joined:
    Apr 14, 2003
    Messages:
    223
    Likes Received:
    0
    Trophy Points:
    16
    vishal thanks, that fixed it for my client. A module wasnt installed and now its fixed.
     
  16. vishal

    vishal Well-Known Member

    Joined:
    Jan 28, 2003
    Messages:
    340
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    India
    My Pleasure!!!

    .
     
  17. MarkB

    MarkB Well-Known Member

    Joined:
    Feb 1, 2003
    Messages:
    46
    Likes Received:
    0
    Trophy Points:
    6
    For some reason it's started working again LOL Maybe my host fixed something, who knows... who cares, as long as it's working ;)
     
  18. oderland

    oderland Well-Known Member
    PartnerNOC

    Joined:
    Dec 30, 2002
    Messages:
    103
    Likes Received:
    0
    Trophy Points:
    16
    Location:
    Kungsbacka, Sweden
    all our servers stoped parsing cgi

    Hi there

    All of our servers stopped parsing cgi scripts . Just followed this conversation but nothing helped.

    We have for example this test script at
    http://emw.se/cgi-bin/test.cgi


    permission 755


    #!/usr/local/bin/perl
    ###################################
    use CGI;
    use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
    ###################################
    print "Content-type: text/html";

    print "Cgi testing...";

    exit;

    error.log file says just:

    [Sun May 25 21:05:52 2003] [error] [client 213.212.44.59] Premature end of script headers: /home/emwse/public_html/cgi-bin/test.cgi
    [Sun May 25 21:05:52 2003] [error] [client 213.212.44.59] File does not exist: /home/emwse/public_html/500.shtml

    We did not get any help from DarkOrb btw

    /Jack

    cPanel.net Support Ticket Number:
     
  19. Website Rob

    Website Rob Well-Known Member

    Joined:
    Mar 23, 2002
    Messages:
    1,506
    Likes Received:
    0
    Trophy Points:
    36
    Location:
    Alberta, Canada
    cPanel Access Level:
    Root Administrator
    Try using:

    print "Content-type: text/html\n\n";

    That is a prerequisite with any Perl script.

    cPanel.net Support Ticket Number:
     
  20. virtuose

    virtuose Member

    Joined:
    Sep 26, 2003
    Messages:
    16
    Likes Received:
    0
    Trophy Points:
    1
    idem

    Hi,

    I have the some error.
    Please, what is the module required for it ?
    But my cgi script doens't work...

    I am :mad: but my script is good on another server without cpanel..

    I have this error:
    malformed header from script. Bad header=<head>: /home/trail/public_html/cgi-bin/admin/admin4.cgi


    Thanks for your help.
     
Loading...

Share This Page