home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.mail.mh
- Path: sparky!uunet!utcsri!geac!torag!jrh!jrh
- From: jrh@jrh.uucp (James R. Hamilton)
- Subject: Re: Incorporating new mail into different folders?
- Message-ID: <1992Nov11.030317.122893@jrh.uucp>
- Organization: private system, Toronto, Ontario
- References: <BxAqrv.603@shakti.ncst.ernet.in>
- Date: Wed, 11 Nov 1992 03:03:17 GMT
- Lines: 75
-
- In article <BxAqrv.603@shakti.ncst.ernet.in> shobhana@shakti.ncst.ernet.in (Shobhana) writes:
- >
- >Hello--
- >
- >Please bear with me if this is an FAQ, but is there any way to
- >incorporate different messages in my maildrop into different folders.
- >Ideally I should be able to do this based on some regular expression
- >on, say, the sender's name.
- >
- Slocal will do the trick. Check out "man slocal" and "man mhook". Also,
- there is more detail available in Chapter 11 of "MH & xmh: E-mail for
- Users and Programmers" by Jerry Peek. Slocal is capable of pattern
- matching but does not support full regular expressions. If you need
- regular expressions in the search strings, the following will work.
-
-
- --jrh
-
-
- #!/bin/sh
- #---------------------------------------------------------------------------
- #
- # FILE: rcvsearch
- # Author: James R. Hamilton
- # Date: 92.10.12 @ 10:37:51
- #
- # USAGE: Rcvsearch search_string maildelivery_program
- #
- # WHERE: Search_string is any egrep legal string and maildelivery_program
- # is any arbitrary maildelivery problem. The key problems with the
- # slocal/.maildelivery combination are the search strings are 1)
- # restricted to header entries only, and 2) restricted to literal
- # matches rather than using fully general regular expressions. If
- # you were searching for root@jrh, you would mistakenly match
- # beatroot@jrh as well. A rcvsearch string of " root@jrh$" avoids
- # this possibility.
- #
- # EXAMPLE: The .maildelivery string:
- #
- # *,-,|,A,/usr/local/lib/mh/rcvsearch '^[^#]*\.x$' \
- # /usr/local/lib/mh/rcvstore +foundit
- #
- # Will store all messages containing a line ending in ".x" without
- # any leading "#" characters. Note that the .maildelivery string
- # must not be continued accros multiple lines as I have here. See
- # the "slocal" and "mhook" man pages for more info.
- #
- # COMMENTS/FIXES TO: James Hamilton <jrh@jrh.gts.org>
- #---------------------------------------------------------------------------
-
- #{ exec >/tmp/rcvsearch.out 2>&1; set -x; } # Uncomment to debug
- PROG=`basename $0`
- if [ $# -lt 2 ] ; then
- echo "$PROG: USAGE: \"$PROG search_string maildelivery_program\"."
- exit 10 # Exit handler not set, return fail.
- fi
- RC=20 # Return code: Assume failure
- tmp=/tmp/$PROG.$$ # Tmp file to store note.
- trap 'rm -f $tmp; exit $RC;' 0 1 2 3 14 15 # Clean up and return RC
- cat >$tmp # Save mail int tmp file.
- egrep "$1" $tmp # Look for search string.
- [ $? != 0 ] && exit # Didn't find it so fail to deliver.
- NewProg="$2" # NewProgram Name is Arg 2.
- shift 2 # get rid of $0,$1, and $2.
- $NewProg "$@" <$tmp # Call the supplied program to process.
- RC=$? # Done, return code is last result.
- exit # Jump to exit handler.
-
- #
- #------------------------------> End of File <------------------------------
- --
-
- James R. Hamilton inet: jrh@jrh.gts.org
- telephone: +1 416 493 4162 uunet: ...!uunet!jrh!jrh
- Toronto, Canada work: jrh@torolab6.vnet.ibm.com
-