procmail
[Top] [All Lists]

Re: Recipe Assistance please anyone

1999-05-31 13:41:51
Colin wrote:
...
      4. (Now things may get tricky I suppose) Write to a file that
will create a date/time stamp, and unique message number (starting maybe
at 1?) for each email that has been recieved and autoreplied to.
Sooooo...this is what I have come up with for handling the mail itself,
but #4 above still has me scratching my brain container.

Here is what I use to generate serial numbers. $REV is the version number of
the rc file, $TZ is the time zone under which the rc operates. Neither of
these are necessary here. $PMSRC is the directory in which I keep auxilliary
procmail rc files. You can use the date and time from the From_ line for your
date-time stamp, as I do, or generate one with the date command at the cost
of another process. Note that the print command below wraps. If print is not
a built-in for your shell, you may want to use echo. In that case, check the
options -- not all echos support \n.

But first, here is how I grab or generate the date-time stamp:

############################################### setup .......... date-time stamp
  :0                          ## From user(_at_)site(_dot_)tld  Fri Jan  1 
01:23:45 1999
  * ^^from ([^ ]+| )  \/... ...  ?..? ..:..:.. ....
  { FDT=$MATCH }              ## grab and save the From DateTime
  :0 E                        ## otherwise settle for unix date, but log it
  { TZ=${TZ:-EST5EDT}         ## my usual haunt, should be defined in .forward
    LOG="**From_ datestamp not found. Using unix date. Whowoodathunkit?$LF"
    :0                        ## NOTE change the date command below on 1/1/2000
    FDT=|date '+%a %h %d %T 19%y'       ## Not all date programs support Y
  }

############################################### setup ............ serial number
## Assign a serial number to this mail. The number is kept in the external    ##
## file $PMRC/serial.rc. This section uses a global lock for serialization.   ##
##   NOTE: the rc file must exist and be seeded with a non-negative value.    ##
## This can be eliminated at the cost of a test -f for each message.          ##
################################################################################
  LOCKFILE=serial.rc$LOCKEXT  ## set global lock
  INCLUDERC=$PMRC/serial.rc   ## read current value
  :0                          ## increment that value by 1
  * $ $SERIAL^0
  *         1^0
  { SERIAL=$= }               ##  and save new value in variable
  :0 w i c                    ## update the history, time stamp, and serial #
  | print "# Serial numbers assigned beginning v5.8 19981117\n# Last message 
v$REV with header date: $FDT $TZ\n#\nSERIAL=$SERIAL" > $INCLUDERC
  LOCKFILE                    ## clear global lock

-- 
Rik Kabel          Old enough to be an adult              
rik(_at_)netcom(_dot_)com

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