Professional Web Applications Themes

Premature Ending of script headers - PERL Modules

I think you guys may be tired of this question.But I don't really know how to solve it. #!/usr/bin/perl print "Context-type: text/html\n\n"; print "Hello EveryOne"; -------------------------------------- Even this sample doesn't work. The perl directory is right. I typed in vi, so I don't think there are any extra characters. The output under the command window is good. Anyone has ideas about this question?...

  1. #1

    Default Premature Ending of script headers

    I think you guys may be tired of this question.But I don't really know
    how to solve it.

    #!/usr/bin/perl
    print "Context-type: text/html\n\n";
    print "Hello EveryOne";

    --------------------------------------
    Even this sample doesn't work. The perl directory is right.
    I typed in vi, so I don't think there are any extra characters.
    The output under the command window is good.
    Anyone has ideas about this question?

    Autumn-Fox Guest

  2. #2

    Default Re: Premature Ending of script headers

    Autumn-Fox wrote:
    > I think you guys may be tired of this question.
    Correct.
    > But I don't really know how to solve it.
    >
    > #!/usr/bin/perl
    > print "Context-type: text/html\n\n";
    > print "Hello EveryOne";
    >
    > --------------------------------------
    > Even this sample doesn't work.
    Try content-type.
    ^

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

  3. #3

    Default Re: Premature Ending of script headers

    it's a mistype.All my .cgi files couldn't run on this machine, which I
    can run on another one.
    I have two versions apache on my machine. If I start 1.3 version, I can
    run all the cgi files.
    If I start 2.2 version, I can't .I really don't know what's wrong with
    all my cgi files.
    Maybe it's a configuration problem.

    I

    Autumn-Fox Guest

  4. #4

    Default Re: Premature Ending of script headers

    Autumn-Fox wrote:
    > I have two versions apache on my machine. If I start 1.3 version, I can
    > run all the cgi files.
    > If I start 2.2 version, I can't .
    That was a rather important piece of info, don't you think?
    > I really don't know what's wrong with all my cgi files.
    Maybe the typo at line 87 ?
    > Maybe it's a configuration problem.
    That does sounds as a much more probable explanation to me.

    Just can't understand why you posted to a Perl group about it. Try An
    apache group instead.

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

  5. #5

    Default Re: Premature Ending of script headers

    Gunnar Hjalmarsson wrote:
    >> But I don't really know how to solve it.
    >>
    >> #!/usr/bin/perl
    >> print "Context-type: text/html\n\n";
    >> print "Hello EveryOne";
    >>
    >> --------------------------------------
    >> Even this sample doesn't work.
    >
    >
    > Try content-type.
    Even more important- set the *correct* Content-type.

    You're setting text/html then sending text/plain. Sort it out...


    --
    Just because I've written it doesn't mean that
    either you or I have to believe it.
    Big and Blue Guest

  6. #6

    Default Re: Premature Ending of script headers

    Here is my problem. I posted it in the apache group and got no answers.
    I tried the way you told me. It won't work.

    Problem: unknown reason to "premature ending of script headers" error
    message

    I run a simple perl cgi problem on my machine.

    ---------------------------hello.cgi-------------------------------
    #! /usr/bin/perl
    use CGI::Carp qw(fatalsToBrowser);
    {
    local ($oldbar) = $|;
    $cfh = select (STDOUT);
    $| = 1;
    print "Content-type: text/html\n\n";
    $| = $oldbar;
    select ($cfh);
    }

    print "hello\n";
    --------------------------------------------------------------------

    I run it in some other places and works fine.

    Now I upload to another server and got the error message I mentioned.(
    I checked it with pico first.)
    I changed my configuration file for httpd as follows:

    uncomment "UserDir public_html",
    uncomment the following:
    <Directory /home/*/public_html>
    AllowOverride FileInfo AuthConfig Limit
    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    <Limit GET POST OPTIONS>
    Order allow,deny
    Allow from all
    </Limit>
    <LimitExcept GET POST OPTIONS>
    Order deny,allow
    Deny from all
    </LimitExcept>
    </Directory>

    add the following
    <Directory /home/*/public_html/cgi-bin>
    Options ExecCGI
    SetHandler cgi-script
    </Directory>

    uncomment addHandler cgi-script .cgi

    -------------------------------------
    Then I changed the following file permissions:
    chmod 711 /home/*
    chmod 755 /home/*/public_html
    chmod 755 /home/*/public_html/*.html
    chmod 755 /home/*/public_html/cgi-bin
    chmod 755 /home/*/public_html/cgi-bin/*.cgi

    And the machine still still gives me the error

    But if I use the ScriptAlias
    ScriptAlias /cgi-bin2/ /home/span/public_html/cgi-bin/

    I can run the hello.cgi well from [url]http://localhost/cgi-bin2/[/url]

    I want to know what could be the reason I can't run my cgi from
    [url]http://localhost/~span/cgi-bin[/url] /hello.cgi
    (span is one of the users ).

    Autumn-Fox Guest

  7. #7

    Default Re: Premature Ending of script headers

    try it before you said it.

    Autumn-Fox Guest

  8. #8

    Default Re: Premature Ending of script headers

    Autumn-Fox wrote:
    > Here is my problem. I posted it in the apache group and got no answers.
    That's not a valid excuse for posting in a Perl group. If you are not
    able to figure it out, hire a consultant.

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

  9. #9

    Default Re: Premature Ending of script headers

    at least my cgi is written in Perl . Is this a good excuse ?
    :)
    Any way, I hate this setting problem. My configuration at least works
    in three machines. Then that stupid server doesn't work for me. I
    really don't know why and I don't have the right to reintall Apache.
    What a pity.

    Autumn-Fox Guest

  10. #10

    Default Re: Premature Ending of script headers

    Problem solved.

    use chown to set the right group/user to the .cgi files and related
    directories.
    chmod 755 to .cgi files.Never ever chmod 777 to .cgi files.

    Autumn-Fox Guest

  11. #11

    Default Re: Premature Ending of script headers

    Autumn-Fox wrote:
    > Problem solved.
    I'm happy for you.
    > use chown to set the right group/user to the .cgi files and related
    > directories.
    > chmod 755 to .cgi files.Never ever chmod 777 to .cgi files.
    Sorry, but I can't help making this off topic follow-up.

    What you just let us know means that your problem was caused by a
    combination of at least two things, none of which you mentioned before:

    1) Some files and/or directories had 777 permissions.

    2) You are running suEXEC or a similar wrapper. Why? Because otherwise
    it would have 'worked' with 777 (even if it's normally crazy to make CGI
    scripts world writable).

    If you are running suEXEC, more meaningful info about what was causing
    the error could probably have been found in suexec.log.

    --
    Gunnar Hjalmarsson
    Email: [url]http://www.gunnar.cc/cgi-bin/contact.pl[/url]
    Gunnar Hjalmarsson Guest

Similar Threads

  1. CGI: Premature end of script headers
    By Perldiscuss - Perl Newsgroups And Mailing Lists in forum PERL Beginners
    Replies: 1
    Last Post: January 15th, 02:49 PM
  2. #14822 [Com]: Premature end of script headers: C:/php/php.exe
    By kurt at k2host dot net in forum PHP Development
    Replies: 3
    Last Post: November 3rd, 04:20 AM
  3. #25485 [Bgs]: Premature end of script headers: php.exe
    By runtimeterror at kaiundina dot de in forum PHP Development
    Replies: 0
    Last Post: September 11th, 06:30 PM
  4. #25485 [Opn->Bgs]: Premature end of script headers: php.exe
    By sniper@php.net in forum PHP Development
    Replies: 0
    Last Post: September 11th, 03:39 PM
  5. #25485 [NEW]: Premature end of script headers: php.exe
    By runtimeterror at kaiundina dot de in forum PHP Development
    Replies: 0
    Last Post: September 11th, 09:12 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139