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

CGI Header Problem

Expand Messages
  • Jeff Eggen
    Hi all, I m trying to get a CGI script working on my webserver. When running the script from the command line, there is no problem. When running it on the
    Message 1 of 1 , Mar 8, 2002
    • 0 Attachment
      Hi all,

      I'm trying to get a CGI script working on my webserver. When running the script from the command line, there is no problem. When running it on the webserver via a browser, I get the following error in the server error log:

      trying to POST /~ds6601/cgi-bin/perldoc.cgi, cgi_scan_headers reports: the CGI program /export/home/ds6601/public_html/cgi-bin/perldoc.cgi did not produce a valid header (name without value: got line "name")

      The browser, of course, just reports a 500 error.

      I tried using CGI::Carp qw (fatalsToBrowser) in the script, and then finished each line with an "or die..." line, but that changed nothing. I assume it has something to do with the header created by the CGI module, but I'm not sure. If anyone could tell me what's causing the error, I'd appreciate it.

      Script is below. At this point, I'm less concerned about beauty & efficiency than I am about results. Although, if anyone knows of a better way to get a web server to generate the perldoc output for a given function or module, I'm all ears.

      Thanks,
      Jeff Eggen

      #!/appl/perl/bin/perl -w

      # Script perldoc.cgi

      use strict;
      use CGI::Pretty;
      use CGI::Carp qw(fatalsToBrowser);

      # A script to print out the perldoc for any module
      # or function.

      my $query = new CGI::Pretty;

      print $query->header;
      print $query->start_html("Perldoc Form");
      print $query->h1("Perldoc Form");
      print $query->start_form;
      print "<EM>Enter the function name you are searching for</EM><BR>";
      print $query->textfield('functionname');
      print "<P>";
      print $query->radio_group(-name=>'group_name',
      -values=>['isfunction','notfunction'],
      -default=>'notfunction');
      print $query->reset;
      print $query->submit('Action', 'Print it');
      print $query->endform;
      print $query->hr;

      if ($query->param())
      {
      my $function = $query->param('group_name');
      my $name = $query->param('functionname');
      print "You requested the perldoc output for: ",$name;
      if ( $function eq 'isfunction' )
      {
      my @perldocarray = `/appl/perl/bin/perldoc -f $name`;
      }
      else
      {
      my @perldocarray = `/appl/perl/bin/perldoc $name`;
      }
      chomp @perldocarray;
      foreach my $line (@perldocarray)
      {
      print $line, "<BR>\n";
      }
      }

      print $query->end_html;
      print "\n";
      __END__
    Your message has been successfully submitted and would be delivered to recipients shortly.