i have not been following this thread...but it appears as if you just
want a generic cgi scrip to work...I like to use  &ReadParse for
most of my easy cgi interactions ...heer is a example..

if you had a form varable like so

<input TYPE="text" NAME="email" SIZE=30 style="background-color:
#999999" MAXLENGTH=50>

you could use ReadParse like this...

#!/usr/bin/perl

&ReadParse;    

print "$in{email}\n";

#all you need to do is paste this at the bottom
# of your cgi scrip and refer to the form vars by
#ther name using the method above...

# Adapted from cgi-lib.pl by [EMAIL PROTECTED] 
    # Copyright 1994 Steven E. Brenner 
    sub ReadParse {
      local (*in) = @_ if @_;
      local ($i, $key, $val);
    
      if ( $ENV{'REQUEST_METHOD'} eq "GET" ) { 
        $in = $ENV{'QUERY_STRING'}; 
      } elsif ($ENV{'REQUEST_METHOD'} eq "POST") {
        read(STDIN,$in,$ENV{'CONTENT_LENGTH'});
      } else {
            # Added for command line debugging
            # Supply name/value form data as a command line argument
            # Format: name1=value1\&name2=value2\&... 
            # (need to escape & for shell)
            # Find the first argument that's not a switch (-)
            $in = ( grep( !/^-/, @ARGV )) [0];
            $in =~ s/\\&/&/g;
      }
    
      @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. \0 is the multiple separator
        $in{$key} .= "\0" if (defined($in{$key})); 
        $in{$key} .= $val;
      }
      return length($in);
    }  


good luck,
jd

fine jewelry

http://www.kastnerotte.com




On Wed, 2003-01-29 at 11:58, Ron Geringer wrote:
> Here is the script from my linux box. I'm running it pretty much the way I
> took it off the web except I changed the reply-to my email and put the "\"
> before the "@".
> 
> I've named the script "test.cgi" and put it in my cgi-bin directory on the
> linux box.
> 
> The html document is in the www/html directory under a subdirectory entitled
> "test"
> 
> Perl Script:
> 
> -----------------------------------------------
> 
> #!/usr/bin/perl
> use CGI;
> 
> my $query    = new CGI;
> my $sendmail = "/usr/sbin/sendmail -t";
> my $reply_to = "Reply-to: geringer2\@cox.net";
> my $subject  = "Subject: Confirmation of your submission";
> my $content  = "Thanks for your submission.";
> my $to       = $query->param('send_to');
> my $file     = "subscribers.txt";
> 
> unless ($to) {
>    print $query->header;
>    print "Please fill in your email and try again";
> }
> 
> open (FILE, ">>$file") or die "Cannnot open $file: $!";
> print $to,"\n";
> close(FILE);
> 
> my $send_to  = "To: ".$query->param('send_to');
> 
> open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail: $!";
> print SENDMAIL $reply_to;
> print SENDMAIL $subject;
> print SENDMAIL $to;
> print SENDMAIL "Content-type: text/plain\n\n";
> print SENDMAIL $content;
> close(SENDMAIL);
> 
> print $query->header;
> print "Confirmation of your submission will be emailed to you.";
> ~
> 
> -----------------------------------------------------------------------
> 
> HTML Script
> 
> -----------------------------------------------------------------------
> 
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
> <html>
> <head>
> <title>Untitled Document</title>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> </head>
> 
> <body>
> <FORM method="POST" action="../../cgi-bin/test/test.cgi">
> <INPUT type="text" name="send_to">
> <INPUT type="submit">
> </FORM>
> 
> 
> </body>
> </html>
> 
> ---------------------------------------------------------
> 
> Thanks
> 
> -----Original Message-----
> From: Dan Muey [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 29, 2003 12:14 PM
> To: Ron Geringer
> Subject: RE: Need help
> 
> 
> 
> 
> >
> > Tbe query variable is the variable email that the html
> > document inserts and passes on to the perl script. I'm
> > assuming that the $query works with send_to as the original
> > sender. What's really confusing is that when I write a tcl
> > script - I just hardcode the receiver's email (much like the
> > perl script does here), I grab the user's email (usually from
> > a database), assign a variable to it and add that veriable to
> > the same line as the hardcoded email --- and all this is sent
> > using open $XXXXX --- multiple prints and the close. Its real
> > easy. Unfortunately, not all servers have tcl loaded so I've
> > got to fall back and learn perl.
> >
> > I've been working with a number of perl scripts and so far I
> > haven't gotten any of them to work - even if I don't get an
> > error, it still doesn't send anything.
> >
> > -----Original Message-----
> > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, January 29, 2003 11:52 AM
> > To: Ron Geringer
> > Subject: RE: Need help
> >
> >
> >
> > Don't forget to posyt to list and not just the orginal sender!!
> > >
> > > Dan:
> > >
> > > except that I ran the same script on my local linux box and got a
> > > similar error regarding headers:
> > >
> > > [Wed Jan 29 09:44:52 2003] [error] [client 192.168.0.202] malformed
> > > header from script. Bad [EMAIL PROTECTED]: /var/www/cgi-b
> > > in/test/test.cgi.
> >
> > Copy the line that has the $to line in it and send it here.
> >
> > >
> > > Same code that I'm trying to run on the server.
> > >
> > > -----Original Message-----
> > > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, January 29, 2003 11:18 AM
> > > To: Ron Geringer
> > > Subject: RE: Need help
> > >
> > >
> > >
> > >
> > > >
> > > > Dan:
> > > >
> > > > you are right - I could have been a little clearer.
> > > >
> > > > Here's the actual error from the log that I get when I run
> > > the script:
> > > >
> > > > qmail-inject: fatal: unable to parse this line:
> > > > Reply-to: [EMAIL PROTECTED]: Confirmation of your
> > > > [EMAIL PROTECTED]: text/plain
> > > > [Wed Jan 29 12:05:44 2003] [error] [client 68.13.40.38] malformed
> > > > header from script. Bad [EMAIL PROTECTED]
> > >
> > > If you're using qmail it would be better to have the
> > qmail-inject path
> > > instead of sendmail which is probably a sym link to qmail-inject.
> > >
> > > To open a pipe to qmail-inject you need
> > /var/qmail/bin/qmail-inject -f
> > > $to_address
> > >
> > > Which means you'll have to modify the open statement to use that.
> > >
> > > Do you know what the -i and -t options do for qmail-inject?
> > >
> > > See you're trying to use sendmail's switches with qmail, do
> > they work,
> > > have the same options, probably not.
> > >
> > > Could be those switches are causing the bad header becaue
> > what they do
> > > in sendmail could be totally different than qmail. That is why it's
> > > best to use a module or at least use the right program/options.
> > >
> > > Dan
> > >
> > > >
> > > > Ron
> > > >
> > > > -----Original Message-----
> > > > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > > > Sent: Wednesday, January 29, 2003 10:56 AM
> > > > To: Ron Geringer; [EMAIL PROTECTED]
> > > > Subject: RE: Need help
> > > >
> > > >
> > > > > I'm pretty much used to scripting sendmail applications in
> > > > tcl - and
> > > > > I'm very new to perl so this may be a dumb question. I'm
> > > > working with
> > > > > a sendmail script that I got off the internet. The script
> > > that I'm
> > > > > working with is listed below:
> > > > >
> > > > > #!/usr/bin/perl
> > > > > use CGI;
> > > > >
> > > > > my $query    = new CGI;
> > > > > my $sendmail = "/usr/sbin/sendmail -i -t";
> > > > > my $reply_to = "Reply-to: geringer2\@cox.net";
> > > > > my $subject  = "Subject: Confirmation of your submission"; my
> > > > > $content  = "Thanks for your submission.";
> > > > > my $to       = $query->param('send_to');
> > > > > my $file     = "subscribers2.txt";
> > > > >
> > > > > unless ($to) {
> > > > >    print $query->header;
> > > > >    print "Please fill in your email and try again";
> > > > > }
> > > > >
> > > > > open (FILE, ">>$file") or die "Cannnot open $file: $!"; print
> > > > > $to,"\n"; close(FILE);
> > > > >
> > > > > my $send_to  = "To: ".$query->param('send_to');
> > > > >
> > > > > open(SENDMAIL, "|$sendmail") or die "Cannot open $sendmail:
> > > > $!"; print
> > > > > SENDMAIL $reply_to; print SENDMAIL $subject; print SENDMAIL
> > > > $to; print
> > > > > SENDMAIL "Content-type: text/plain\n\n"; print SENDMAIL
> > $content;
> > > > > close(SENDMAIL);
> > > > >
> > > > > print $query->header;
> > > > > print "Confirmation of your submission will be emailed to
> > > you."; ~ ~
> > > > >
> > > > > --------------------------------------
> > > > >
> > > > > The only difference between this and the one I found is
> > > the "\" in
> > > > > fron of the "@". When I run this cript - the error that I'm
> > > > seeing  is
> > > > > that the header is malformed.
> > > >
> > > > If what you're trying to get help on is the malformed
> > header error
> > > > then this is probably the problem :
> > > >
> > > > You should need to do \@ if you're using double quotes,
> > > shouldn't need
> > > > if you use single quotes.
> > > >
> > > > Did having that ( the \ in front of the @ ) cause the
> > > error? Could you
> > > > be less ambiguous about the problem, is the problem the 'header
> > > > malformed' error or you can't send mail or ...? What
> > > happens when you
> > > > run it form the command line?
> > > >
> > > > You might want to look into a module, they're much easier
> > > to work with
> > > > and portable. The one I started working wioth lately is :
> > > > http://search.cpan.org/author/JENDA/Mail-Sender-0.8.04/Sender.
> > > pm
> > >
> > > Or search cpan and find one you like/does what you want and you'll
> > > probably on ly need a few lines of code to do what you want.
> > >
> > > Dan
> > >
> > > >
> > > > If anyone can tell me what I did wrong - I would appreciate it.
> > > >
> > > > What I'm trying to do is put a perl script on a server
> > > which will take
> > > > data from an html document and redirect it to an email
> > > address. Once I
> > > > get one to work, I'm confident that I can make
> > > modifications and work
> > > > with it (testing etc), to better understand how perl
> > makes it works.
> > > >
> > > > I would really appreciate any help I can get.
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > >
> > > >
> > >
> > >
> >
> >



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to