[102180] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: Internal HTTP ERROR.

daemon@ATHENA.MIT.EDU (hUnTeR)
Tue Dec 1 19:12:49 1998

Date: Tue, 01 Dec 1998 19:08:14 -0500
From: hUnTeR <hunter@esprit.net>
To: redhat-list@redhat.com, aromes@microtec.net
Resent-From: redhat-list@redhat.com
Reply-To: redhat-list@redhat.com

This is a multi-part message in MIME format.
--------------659B39E8459D4A85110B80E1
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

aromes

I found some syntactical errors in your html and perl scripts. Some
missing quotes for one!! Gotta watch those, they maybe lame little
creatures, but necessary when coding. I got the html to work, the
mailer.pl to work (after some editing) but i gave up on the cgi.pl and
suggest you try the attached cgi-lib.pl. Place the *.pl files in your
/home/httpd/cgi-bin and chmod 755 *.pl then replace your html with my
paste and edit accordingly, it should work!!

html:

<HTML>
<HEAD>
<TITLE>hello</TITLE>
</HEAD>
<BODY>
<H1>Send mail to me</H1>
<P>you can use this form to send me mail.
<p><hr><p>

<form method="POST" action="http://your.web.server/cgi-bin/mailer.pl">
<input name="from"> Your email address<p>
<input name="subject"> Subject<p>
<input type=hidden name  value="you@yourdomain">
<hr>
Enter message body below:<br>
<textarea name="body" cols=60 rows=12></textarea><p>
<hr>
<input type=submit value="Send mail"><p>
</form>

</BODY>
</HTML>


mailer.pl

#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse;

print "Content-type: text/html\n\n";
print "<title>Mail form results</title>";
print "<h1>Mail form results</h1>";

open (MAIL, "/usr/sbin/sendmail $to")  ||
 die "<p>Error: Couldn't execute sendmail.</p>\n";
print MAIL "To:  $in{'to'}\n";
print MAIL "From: $in{'from'}\n";
print MAIL "subject: $in{'subject'}\n\n";
print MAIL "$in{'body'}\n";
close MAIL;

print "<p>All right mailed the following to <tt>$to</tt>:\n";
print "<p><pre>";
print "To: $in{'to'}\n";
print "From: $in{'from'}\n";
print "Subject: $in{'subject'}\n\n";
print "$in{'body'}\n";
print "</pre>";


And again, i gave up trying to hack thru your cgi.pl and instead used a
cgi-lib.pl i had on my machine.

Hope this helped, and good luck!!
-- 
Michael B. Weiner
Systems Administrator/Partner
The UserFriendly Network (UFN)
--

             / /  (_)__  __ ____  __
            / /__/ / _ \/ // /\ \/ /  
           /____/_/_//_/\_,_/ /_/\_\ 

     * * * CHOICE OF A GNU GENERATION * * *

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.5.5 for non-commercial use
Comment: Public key available at http://pgpkeys.mit.edu
and http://www.userfriendly.net/pgp_key.asc

iQA/AwUBNQreROCbl6l4t9akEQJRagCfTDSULZQS/Iv0dFWdFMJa2F0N4vkAoKhh
zh5u4pHu75zfXwXK9PNU2Y5u
=kO+N
-----END PGP SIGNATURE-----
--------------659B39E8459D4A85110B80E1
Content-Type: application/x-perl; name="cgi-lib.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="cgi-lib.pl"

#!/usr/bin/perl -- -*- C -*-

# Perl Routines to Manipulate CGI input
# S.E.Brenner@bioc.cam.ac.uk
# $Header: /cys/people/seb1005/http/cgi-bin/RCS/cgi-lib.pl,v 1.6 1994/07/13 15:00:50 seb1005 Exp $
#
# Copyright 1994 Steven E. Brenner  
# Unpublished work.
# Permission granted to use and modify this library so long as the
# copyright above is maintained, modifications are documented, and
# credit is given for any use of the library.
#
# Thanks are due to many people for reporting bugs and suggestions
# especially Meng Weng Wong, Maki Watanabe, Bo Frese Rasmussen,
# Andrew Dalke, Mark-Jason Dominus. 

# see http://www.seas.upenn.edu/~mengwong/forms/   or
#     http://www.bio.cam.ac.uk/web/                for more information

# Minimalist http form and script (http://www.bio.cam.ac.uk/web/minimal.cgi):
# if (&MethGet) {
#   print &PrintHeader,
#       '<form method=POST><input type="submit">Data: <input name="myfield">';
# } else {
#   &ReadParse(*input);
#   print &PrintHeader, &PrintVariables(%input);
# }


# MethGet
# Return true if this cgi call was using the GET request, false otherwise
# Now that cgi scripts can be put in the normal file space, it is useful
# to combine both the form and the script in one place with GET used to
# retrieve the form, and POST used to get the result.

sub MethGet {
  return ($ENV{'REQUEST_METHOD'} eq "GET");
}

# ReadParse
# Reads in GET or POST data, converts it to unescaped text, and puts
# one key=value in each member of the list "@in"
# Also creates key/value pairs in %in, using '\0' to separate multiple
# selections

# If a variable-glob parameter (e.g., *cgi_input) is passed to ReadParse,
# information is stored there, rather than in $in, @in, and %in.

sub ReadParse {
    local (*in) = @_ if @_;


  local ($i, $loc, $key, $val);

  # Read in text
  if ($ENV{'REQUEST_METHOD'} eq "GET") {
    $in = $ENV{'QUERY_STRING'};
  } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
    read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
  }

  @in = split(/&/,$in);

  foreach $i (0 .. $#in) {
    # Convert plus's to spaces
    $in[$i] =~ s/\+/ /g;

    # Split into key and value.  
    ($key, $val) = split(/=/,$in[$i],2); # splits on the first =.

    # Convert %XX from hex numbers to alphanumeric
    $key =~ s/%(..)/pack("c",hex($1))/ge;
    $val =~ s/%(..)/pack("c",hex($1))/ge;

    # Associate key and value
    $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
    $in{$key} .= $val;

  }

  return 1; # just for fun
}

# PrintHeader
# Returns the magic line which tells WWW that we're an HTML document

sub PrintHeader {
  return "Content-type: text/html\n\n";
}

# Note: Neither of the PrintVariables functions deals with multiple
#       occurences of keys

# PrintVariables
# Nicely formats variables in an associative array passed as a parameter
# And returns the HTML string.

sub PrintVariables {
  local (%in) = @_;
  local ($old, $out, $output);
  $old = $*;  $* =1;
  $output .=  "<DL COMPACT>";
  foreach $key (sort keys(%in)) {
    ($out = $in{$key}) =~ s/\n/<BR>/g;
    $output .=  "<DT><B>$key</B><DD><I>$out</I><BR>";
  }
  $output .=  "</DL>";
  $* = $old;

  return $output;
}

# PrintVariablesShort
# Nicely formats variables in an associative array passed as a parameter
# Using one line per pair (unless value is multiline)
# And returns the HTML string.


sub PrintVariablesShort {
  local (%in) = @_;
  local ($old, $out, $output);
  $old = $*;  $* =1;
  foreach $key (sort keys(%in)) {
    if (($out = $in{$key}) =~ s/\n/<BR>/g) {
      $output .= "<DL COMPACT><DT><B>$key</B> is <DD><I>$out</I></DL>";
    } else {
      $output .= "<B>$key</B> is <I>$out</I><BR>";
    }
  }
  $* = $old;

  return $output;
}

1; #return true

--------------659B39E8459D4A85110B80E1--


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post