Loading ...
Sorry, an error occurred while loading the content.

Premature end of CGI...

Expand Messages
  • shraddha more
    Hello Out of above 2 attached files I could run form.cgi from Browser but could not run test.cgi since it was giving error as Premature end of script Can
    Message 1 of 2 , Mar 2, 2004
    • 0 Attachment
      Hello

      Out of above 2 attached files I could run form.cgi from Browser but could not run test.cgi since it was giving error as 'Premature end of script'
      Can anybody guess what must be the cause?

      Shraddha



      Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more.
      ----------

      #!/usr/bin/perl -w
      use CGI qw(:standard);
      use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
      use strict;
      use Fcntl qw(:flock :seek);

      my $outfile = "b.txt";

      print header;
      print start_html("Results");

      # open the file for reading
      open(IN, "$outfile") or &dienice("Couldn't open $outfile: $!");
      # set a shared lock
      flock(IN, LOCK_SH);
      # then seek the beginning of the file
      seek(IN, 0, SEEK_SET);

      # declare the totals variables
      my ($total_votes, %results);
      # initialize all of the counts to zero:
      foreach my $i ("fotr", "ttt", "rotk", "none") {
      $results{$i} = 0;
      }

      while (my $rec = <IN>) {
      chomp($rec);
      $total_votes = $total_votes + 1;
      $results{$rec} = $results{$rec} + 1;
      }
      close(IN);

      # now display a summary:
      print <<End;
      <b>Which was your favorite <i>Lord of the Rings</i> film?</b><br>
      <table border=0 width=50%>
      <tr>
      <td>The Fellowship of the Ring</td>
      <td>$results{fotr} votes</td>
      </tr>
      <tr>
      <td>The Two Towers</td>
      <td>$results{ttt} votes</td>
      </tr>
      <tr>
      <td>Return of the King</td>
      <td>$results{rotk} votes</td>
      </tr>
      <tr>
      <td>didn't watch them</td>
      <td>$results{none} votes</td>
      </tr>
      </table>
      <p>
      $total_votes votes total
      </p>
      End

      print end_html;

      sub dienice {
      my($msg) = @_;
      print h2("Error");
      print $msg;
      print end_html;
      exit;
      }

      ----------


      #!/usr/bin/perl -w
      use CGI qw(:standard);
      use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
      use strict;
      use Fcntl qw(:flock :seek);

      #===============================
      # Testing CGI script installation
      # Copyright 1999-2001, Emmie P. Lewis
      # Created 07/24/99
      #===============================
      # This script is designed to test
      # CGI script installation
      #===============================

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

      print "Yippee! It works!";


      [Non-text portions of this message have been removed]
    • daymobrew@yahoo.com
      ... could not run test.cgi since it was giving error as Premature end of script ... There is nothing wrong with the test.cgi script. The permissions on the
      Message 2 of 2 , Mar 3, 2004
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, shraddha more
        <its_shraddham@y...> wrote:
        > Hello
        >
        > Out of above 2 attached files I could run form.cgi from Browser but
        could not run test.cgi since it was giving error as 'Premature end of
        script'
        > Can anybody guess what must be the cause?
        >
        > Shraddha
        >
        >
        >
        > ----------
        >
        >
        > #!/usr/bin/perl -w
        > use CGI qw(:standard);
        > use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
        > use strict;
        > use Fcntl qw(:flock :seek);

        >
        > #===============================
        > # Testing CGI script installation
        > # Copyright 1999-2001, Emmie P. Lewis
        > # Created 07/24/99
        > #===============================
        > # This script is designed to test
        > # CGI script installation
        > #===============================
        >
        > print "Content-type: text/plain\n\n";
        >
        > print "Yippee! It works!";
        >
        >

        There is nothing wrong with the test.cgi script. The permissions on
        the file are probably not correct - it should be world readable and
        world executable.

        Aside: If you are only using test.cgi as it currently is, you won't
        need any of the modules you have included.
      Your message has been successfully submitted and would be delivered to recipients shortly.