procmail
[Top] [All Lists]

Re: send file [size] recipe wanted

1996-03-23 02:05:02
On Fri, 22 Mar 1996 10:12:31 -0500 (EST),
Stan Ryckman <stanr(_at_)sunspot(_dot_)tiac(_dot_)net> wrote:
If a msg. comes in (any body or none), and the subject BEGINS "send ", I
want it to parse out the rest as in this example:
It's undoubtedly not the best or fastest way to do this, but
if you have SOME_STRING and want, say, the second word from it:
     WORD2=`echo $SOME_STRING | awk '{print $2}' -`
ought to do the trick.

If you're relying on awk, why not do all the parsing in awk (or,
better yet, Perl (^:

  :0
  ^Subject: send .*
  | /your/awk-or-perl/mail/responder/here

That's how I might do it (instead of learning how to do it properly :-)

/* era */


send uuencode sat-am.zip 1000

#!/usr/local/bin/perl
# Simplistic and sketchy, and not even syntax checked
# Note Perl RE wants no backslashes for group parens -- \( is literal paren

# If you want no error checking, use #!perl -p and remove this loop etc ...

while (<>)
{
    last if ($what & $where); # Stop looping if we have what we need

    # If I were you I'd put the "what" first and make the others
    #  optional, say with the defaults uuencode and no splitting

    ($how, $what, $dummy, $split) = 
        m/^Subject: send (\s+)\S+(\s+)(\S+(\s+))?/ && next;

    ($where) = m/^From: (.*)/ && next;
}

exec ("how-to-send", "-chunk=$split", "$what", "$where" "-and=$how")
    if ($what & $where);

# Maybe some kind of error checking if it falls thru?

-- 
See <http://www.ling.helsinki.fi/~reriksso/> for mantra, disclaimer, etc.

<Prev in Thread] Current Thread [Next in Thread>