Randy wrote:
So... allow me to cut to the chase. What I am after is the ability to
catch incoming mail (to a specific address), from there I would like to see
if the subject line contains a ticket number. If one is not present, I
would like to increment and assign a ticket number from a data file, and
then of course save the new value back to file.
Here's a snippet from my rc.
############################################### 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. ##
## NOTE, too: this can cause a bottleneck if a lot of mail arrives at once. ##
################################################################################
holdLogA=$LOGABSTRCT ## save value around section
LOGABSTRACT=no ## do not log next actions
LOCKFILE=serial.rc$LOCKEXT ## set global lock
INCLUDERC=$pmrc/serial.rc ## read current value
:0 ## increment value just read by 1
* $ $serial^0
* 1^0
{ serial=$= } ## save new value in variable
:0 w i c ## rewrite the serial number file
| print "# serial numbers assigned beginning 19981117\n\
serial=$serial" > $INCLUDERC
LOCKFILE ## clear global lock
LOGABSTRACT=$holdLogA ## restore log abstract setting
You may prefer to use echo to print. If you do, make sure that newlines
are indicated and processed the way you want.
To to what you want, this needs to be wrapped in a recipe that checks
for an existing ticket number. We do that like this:
:0
* ! ^subject:.*\<[a-z][0-9][0-9][0-9][0-9]\>
{
all of my stuff, above, goes here, modified as needed to reference
your ticket number generation algorithm
}
This will run the generator for every message which doesn't have a
string matching the regexp \<[a-z][0-9][0-9][0-9][0-9]\>. Change that
regexp to match your pattern.
If we want to carry the ticket number forward, we might do:
:0
* ^subject:.\<\/ticketregexp\>
{ ticket=$MATCH }
:0 E
{
ticket generator which leaves new
ticket number in variable ticket
}
--
Rik Kabel Click **HERE** to lower control rods
rik(_at_)netcom(_dot_)com