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.

cgi not working Premature end of script headers

Discussion in 'General Discussion' started by NoAgendas, Aug 14, 2006.

  1. NoAgendas

    NoAgendas Guest

    Getting Premature end of script headers on all cgi files

    They are 755 chmodded

    I did not use ftp, I used scp to transfer them from one server to another.

    I'm assuming this might be why they are not working, but I do not know

    The apache logs only shows "Premature end of script headers"

    How do I correct this?
     
  2. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    If they were transferred in binary mode they will give that error.
     
  3. NoAgendas

    NoAgendas Guest

    How do I transfer in ASCII mode using scp?
     
  4. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Interesting question. Maybe binary/ascii doesn't apply with scp.

    The script did work on the other server, right?


    Add this
    use CGI::Carp qw(fatalsToBrowser);
    near the top of the script and see if it helps.
     
  5. NoAgendas

    NoAgendas Guest

    I downloaded the files locally, re-uploaded via ftp in ascii mode. I still get Internal Server Error message.

    [Mon Aug 14 22:04:19 2006] [error] [client xx.xxx.19.185] Premature end of script headers: /home/user/public_html/cgi-bin/search.cgi
    [Mon Aug 14 22:04:19 2006] [error] [client xx.xxx.19.185] File does not exist: /home/user/public_html/500.shtml
     
  6. PWSowner

    PWSowner Well-Known Member

    Joined:
    Nov 10, 2001
    Messages:
    2,948
    Likes Received:
    3
    Trophy Points:
    38
    Location:
    ON, Canada
    Does the fatalsToBrowser line show anything when going to the script?
     
  7. Anishts

    Anishts Active Member

    Joined:
    Oct 6, 2005
    Messages:
    37
    Likes Received:
    0
    Trophy Points:
    6
    hi

    Check suexec log...
     
  8. NoAgendas

    NoAgendas Guest

    suexec log:

    [2006-08-15 13:12:22]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:19:30]: info: (target/actual) uid: (seekorg/seekorg) gid: (seekorg/seekorg) cmd: search.cgi
    [2006-08-15 13:19:46]: info: (target/actual) uid: (seekorg/seekorg) gid: (seekorg/seekorg) cmd: search.cgi
    [2006-08-15 13:20:43]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:20:44]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:20:45]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:23:12]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:23:12]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:23:47]: info: (target/actual) uid: (gotorg/gotorg) gid: (gotorg/gotorg) cmd: fpexe
    [2006-08-15 13:37:09]: info: (target/actual) uid: (seekorg/seekorg) gid: (seekorg/seekorg) cmd: search.cgi

    I tried chmodding the cgi files to 711, 755 and 777 - none worked
     
    #8 NoAgendas, Aug 15, 2006
    Last edited by a moderator: Aug 15, 2006
  9. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    I assume you've checked the basics?

    - File owership correct?
    - File permissions correct (no XXX7)
    - Parent directory permissons correct (no XXX7)
    - Definitely uploaded in ASCII mode?

    Try running an affected script through the command line tool dos2unix. This will convert Windows-style line returns to Unix style (\r\n to \n if I remember correctly). Extraneous carriage returns can sometimes annoy things.
     
  10. NoAgendas

    NoAgendas Guest

    Code:
    root@host [/home/seekorg/public_html/cgi-bin]# ls -lh
    total 226M
    drwxr-xr-x   2 seekorg seekorg 4.0K Aug 14 23:32 ./
    drwxr-x---  10 seekorg nobody  4.0K Aug 14 23:18 ../
    -rw-r--r--   1 seekorg seekorg  18K Aug 14 21:45 cgiecho
    -rw-r--r--   1 seekorg seekorg  18K Aug 14 21:45 cgiemail
    -rwxrwxrwx   1 seekorg seekorg 2.9K Aug 14 21:45 entropybanner.cgi*
    -rwxrwxrwx   1 seekorg seekorg 2.9K Aug 14 21:45 randhtml.cgi*
    -rwxr-xr-x   1 seekorg seekorg 132K Aug 14 21:59 search.cgi*
    -rwxrwxrwx   1 seekorg seekorg 7.8K Aug 14 21:45 search_template.html*
    -rwxrwxrwx   1 seekorg seekorg  25K Aug 14 21:45 searchwords.log*
    -rwxrwxrwx   1 seekorg seekorg 3.3K Aug 14 21:59 settings.zdat*
    -rwxrwxrwx   1 seekorg seekorg 483K Aug 14 22:53 zoom_datetime.zdat*
    -rwxrwxrwx   1 seekorg seekorg 1.1M Aug 14 22:52 zoom_descriptions.zdat*
    -rwxrwxrwx   1 seekorg seekorg 7.1M Aug 14 22:01 zoom_dictionary.zdat*
    -rwxrwxrwx   1 seekorg seekorg 1.2M Aug 14 22:53 zoom_pages.zdat*
    -rwxrwxrwx   1 seekorg seekorg 107M Aug 14 23:59 zoom_pagetext.zdat*
    -rwxrwxrwx   1 seekorg seekorg 989K Aug 14 22:53 zoom_titles.zdat*
    -rwxrwxrwx   1 seekorg seekorg 108M Aug 14 22:35 zoom_wordmap.zdat*
    root@host [/home/seekorg/public_html/cgi-bin]# dos2unix search.cgi
    dos2unix: converting file search.cgi to UNIX format ...
    root@host [/home/seekorg/public_html/cgi-bin]# dos2unix entropybanner.cgi
    dos2unix: converting file entropybanner.cgi to UNIX format ...
    root@host [/home/seekorg/public_html/cgi-bin]# dos2unix randhtml.cgi
    dos2unix: converting file randhtml.cgi to UNIX format ...
    
    Permissions correct on the above

    cgi-bin chmod to 755 as well

    Uploaded in ASCII using FileZilla, 100% positive on that.

    Code:
    root@host [/home/seekorg/public_html/cgi-bin]# dos2unix *
    dos2unix: converting file cgiecho to UNIX format ...
    dos2unix: converting file cgiemail to UNIX format ...
    dos2unix: converting file entropybanner.cgi to UNIX format ...
    dos2unix: converting file randhtml.cgi to UNIX format ...
    dos2unix: converting file search.cgi to UNIX format ...
    dos2unix: converting file search_template.html to UNIX format ...
    dos2unix: converting file searchwords.log to UNIX format ...
    dos2unix: converting file settings.zdat to UNIX format ...
    dos2unix: converting file zoom_datetime.zdat to UNIX format ...
    dos2unix: converting file zoom_descriptions.zdat to UNIX format ...
    dos2unix: converting file zoom_dictionary.zdat to UNIX format ...
    dos2unix: converting file zoom_pages.zdat to UNIX format ...
    dos2unix: converting file zoom_pagetext.zdat to UNIX format ...
    dos2unix: converting file zoom_titles.zdat to UNIX format ...
    dos2unix: converting file zoom_wordmap.zdat to UNIX format ...
    root@host [/home/seekorg/public_html/cgi-bin]# tail -f /usr/local/apache/logs/error_log
    [Tue Aug 15 14:10:23 2006] [error] [client xxx.xxx.19.185] Premature end of script headers: /home/seekorg/public_html/cgi-bin/search.cgi
    [Tue Aug 15 14:10:23 2006] [error] [client xxx.xxx.19.185] File does not exist: /home/seekorg/public_html/500.shtml
    
    suexec logs:

    [2006-08-15 14:10:23]: info: (target/actual) uid: (seekorg/seekorg) gid: (seekorg/seekorg) cmd: search.cgi
    [2006-08-15 14:10:23]: error: target uid/gid (32011/32013) mismatch with directory (32011/32013) or program (0/0) or trusted user (0/10)
     
  11. NoAgendas

    NoAgendas Guest

    That was the last I tried. What is the proper permission?

    I tried the 3 711, 755, 777 and none worked.

    I even disabled suexec, also did not work
     
  12. webignition

    webignition Well-Known Member

    Joined:
    Jan 22, 2005
    Messages:
    1,880
    Likes Received:
    0
    Trophy Points:
    36
    Maybe I'm reading this wrong, but isn't '-rwxrwxrwx' '0777' - i.e. incorrect permissions?
     
  13. nickp666

    nickp666 Well-Known Member

    Joined:
    Jan 28, 2005
    Messages:
    770
    Likes Received:
    2
    Trophy Points:
    18
    Location:
    /dev/null
    Try the 'Fix Insecure permissions' script from WHM, definatly sounds like an suexec problem, if you are using suexec 0644 should work.
     
  14. DigitalN

    DigitalN Well-Known Member

    Joined:
    Sep 23, 2004
    Messages:
    420
    Likes Received:
    1
    Trophy Points:
    18
    Running the script from command line, will usally tell you what's wrong, if there is something wrong with the script itself, causing the error.


    # perl -w script.cgi
     
  15. BPrintz

    BPrintz Registered

    Joined:
    Oct 28, 2004
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Did you ever solve this problem, I have the same thing now... the scripts are valid and will run from shell, they use to be running from the cgi-bin however no longer seem to work.... very stange. Any insight?
     
  16. 2mhost.com

    2mhost.com Active Member

    Joined:
    Sep 4, 2001
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    if script run from shell and not in browser then remember to specify the output type that suit browsers

    try this:

    #!/usr/local/bin/perl
    print "Content-type: text/html\n\n";
    print "hello world";
     
Loading...

Share This Page