home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / mail / mh / 1275 < prev    next >
Encoding:
Text File  |  1992-11-10  |  3.5 KB  |  86 lines

  1. Newsgroups: comp.mail.mh
  2. Path: sparky!uunet!utcsri!geac!torag!jrh!jrh
  3. From: jrh@jrh.uucp (James R. Hamilton)
  4. Subject: Re: Incorporating new mail into different folders?
  5. Message-ID: <1992Nov11.030317.122893@jrh.uucp>
  6. Organization: private system, Toronto, Ontario
  7. References: <BxAqrv.603@shakti.ncst.ernet.in>
  8. Date: Wed, 11 Nov 1992 03:03:17 GMT
  9. Lines: 75
  10.  
  11. In article <BxAqrv.603@shakti.ncst.ernet.in> shobhana@shakti.ncst.ernet.in (Shobhana) writes:
  12. >
  13. >Hello--
  14. >
  15. >Please bear with me if this is an FAQ, but is there any way to
  16. >incorporate different messages in my maildrop into different folders.
  17. >Ideally I should be able to do this based on some regular expression
  18. >on, say, the sender's name.
  19. >
  20.     Slocal will do the trick.  Check out "man slocal" and "man mhook". Also,
  21.     there is more detail available in Chapter 11 of "MH & xmh: E-mail for
  22.     Users and Programmers" by Jerry Peek.  Slocal is capable of pattern
  23.     matching but does not support full regular expressions.  If you need
  24.     regular expressions in the search strings, the following will work.
  25.     
  26.  
  27.                              --jrh
  28.  
  29.  
  30. #!/bin/sh
  31. #---------------------------------------------------------------------------
  32. #
  33. #            FILE:    rcvsearch
  34. #            Author:    James R. Hamilton
  35. #            Date:    92.10.12 @ 10:37:51
  36. #
  37. #   USAGE: Rcvsearch search_string maildelivery_program
  38. #
  39. #   WHERE: Search_string is any egrep legal string and maildelivery_program
  40. #          is any arbitrary maildelivery problem.  The key problems with the
  41. #          slocal/.maildelivery combination are the search strings are 1)
  42. #          restricted to header entries only, and 2) restricted to literal
  43. #          matches rather than using fully general regular expressions.  If
  44. #          you were searching for root@jrh, you would mistakenly match 
  45. #          beatroot@jrh as well.  A rcvsearch string of " root@jrh$" avoids
  46. #          this possibility.
  47. #
  48. #   EXAMPLE: The .maildelivery string:
  49. #
  50. #         *,-,|,A,/usr/local/lib/mh/rcvsearch '^[^#]*\.x$' \
  51. #             /usr/local/lib/mh/rcvstore +foundit
  52. #
  53. #         Will store all messages containing a line ending in ".x" without
  54. #         any leading "#" characters.  Note that the .maildelivery string 
  55. #         must not be continued accros multiple lines as I have here.  See 
  56. #         the "slocal" and "mhook" man pages for more info. 
  57. #
  58. #   COMMENTS/FIXES TO: James Hamilton <jrh@jrh.gts.org>
  59. #---------------------------------------------------------------------------
  60.  
  61.     #{ exec >/tmp/rcvsearch.out 2>&1; set -x; }        # Uncomment to debug
  62.     PROG=`basename $0`
  63.     if [ $# -lt 2 ] ; then
  64.     echo "$PROG: USAGE: \"$PROG search_string maildelivery_program\"."
  65.         exit 10                # Exit handler not set, return fail.
  66.     fi
  67.     RC=20                # Return code: Assume failure
  68.     tmp=/tmp/$PROG.$$            # Tmp file to store note.
  69.     trap 'rm -f $tmp; exit $RC;' 0 1 2 3 14 15    # Clean up and return RC
  70.     cat >$tmp                # Save mail int tmp file.
  71.     egrep "$1" $tmp            # Look for search string.
  72.     [ $? != 0 ] && exit            # Didn't find it so fail to deliver.
  73.     NewProg="$2"            # NewProgram Name is Arg 2.
  74.     shift 2                # get rid of $0,$1, and $2.
  75.     $NewProg "$@" <$tmp            # Call the supplied program to process.
  76.     RC=$?                # Done, return code is last result.
  77.     exit                # Jump to exit handler.
  78.  
  79. #
  80. #------------------------------> End of File <------------------------------
  81. -- 
  82.  
  83. James R. Hamilton                              inet: jrh@jrh.gts.org
  84. telephone: +1 416 493 4162                     uunet: ...!uunet!jrh!jrh
  85. Toronto, Canada                                work: jrh@torolab6.vnet.ibm.com
  86.