[boulder.pm] file handle and pipe

j davis davis_compz at hotmail.com
Sat Jun 29 02:13:45 CDT 2002


so, the script is not finshed as you can tell. I was just getting
the var passing down cause I'm new to cgi too.anyway here it is, I use the
the perl that you get with rh7.3 and i updated it once using up2date..

perl-5.6.1-34.99.6

thanks
jd

#!/usr/bin/perl

&ReadParse;
print "Content-type: text/html\n\n";

print "<html><head><title>hi</title></head><body>";
print "your mail has been sent all replies will be sent to:";
print "$in{email}\n";
print "</body></html>";

###now open pipe to write to
open(MAIL, "|/usr/sbin/sendmail jd\@taproot.bz");
print MAIL "$in{content}";
close MAIL;

# Adapted from cgi-lib.pl by S.E.Brenner at bioc.cam.ac.uk
    # 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);
    }




>From: Luke Palmer <fibonaci at babylonia.flatirons.org>
>Reply-To: boulder-pm-list at happyfunball.pm.org
>To: <boulder-pm-list at happyfunball.pm.org>
>Subject: Re: [boulder.pm] file handle and pipe
>Date: Sat, 29 Jun 2002 00:20:06 -0600 (MDT)
>MIME-Version: 1.0
>Received: from mail.pm.org ([64.49.222.22]) by hotmail.com with Microsoft 
>SMTPSVC(5.0.2195.4905); Fri, 28 Jun 2002 23:19:50 -0700
>Received: (from majordomo at localhost)by mail.pm.org (8.11.6/8.11.3) id 
>g5T6RSp18779for boulder-pm-list-outgoing; Sat, 29 Jun 2002 01:27:28 -0500
>Received: from babylonia.flatirons.org 
>(IDENT:lIEHVuSaqlQI1Ll2hymzmlxU/Xam2VSp@[161.97.204.99])by mail.pm.org 
>(8.11.6/8.11.3) with ESMTP id g5T6RR018776for 
><boulder-pm-list at happyfunball.pm.org>; Sat, 29 Jun 2002 01:27:27 -0500
>Received: from localhost (fibonaci at localhost)by babylonia.flatirons.org 
>(8.11.6/8.8.7) with ESMTP id g5T6K6I11811for 
><boulder-pm-list at happyfunball.pm.org>; Sat, 29 Jun 2002 00:20:06 -0600
>X-Authentication-Warning: mail.pm.org: majordomo set sender to 
>owner-boulder-pm-list at pm.org using -f
>In-Reply-To: <F246TRqf69aZbLAX3cf000014f1 at hotmail.com>
>Message-ID: 
><Pine.LNX.4.33.0206290017230.9086-100000 at babylonia.flatirons.org>
>Sender: owner-boulder-pm-list at pm.org
>Precedence: bulk
>Return-Path: owner-boulder-pm-list at mail.pm.org
>X-OriginalArrivalTime: 29 Jun 2002 06:19:50.0774 (UTC) 
>FILETIME=[F9B1E160:01C21F34]
>
>On Sat, 29 Jun 2002, j davis wrote:
>
> >
> > syntax was just a little off
> >
> > open(MAIL, "|/usr/sbin/sendmail jd\@taproot.bz");
>
>The parentheses are all you changed?  This should not make a difference. I
>ran a test on it and it does the exact same thing. In fact, Deparse
>deparses to it without parentheses....
>
>What version are you running?
>Mind attaching me the source so I can have a look at this oddity. If
>nothing else, you've found a bug that I can patch :)
>
>Luke
>
> > print MAIL "$in{content}";
> > close MAIL;
> >
>
> > is what i needed....like i said im new.
> > can all command line based programs be piped into in this manner?
> >
> > thanks
> > jd
> >
> >
> > >Hello,
> > >Im a newbie. I have a var. that holds the contents of a email. I am 
>trying
> > >to send the email using sendmail like this....
> > >
> > >`/bin/echo $in{content} | sendmail jd\@taproot.bz`;
> > >
> > >doesnt work , friend suggested this.....
> > >
> > >open MAIL, "|/usr/bin/sendmail jd\@taproot.bz";
> > >print MAIL "$in{content}";
> > >close MAIL;
> > >
> > >cant seem to make this work either but i really like the idea of it.
> > >can i open a file handel and pipe info into a program like
> > >im trying above?
> > >
> > >thanks,
> > >jd
> > >jd at taproot.bz
> > >http://www.taproot.bz
> > >
> > >_________________________________________________________________
> > >Chat with friends online, try MSN Messenger: http://messenger.msn.com
> >
> >
> > thanks,
> > jd
> >
> > jd at taproot.bz
> > http://www.taproot.bz
> >
> > _________________________________________________________________
> > Join the world’s largest e-mail service with MSN Hotmail.
> > http://www.hotmail.com
> >


thanks,
jd

jd at taproot.bz
http://www.taproot.bz

_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com




More information about the Boulder-pm mailing list