Greetings,
I'm currently working on a multi-directory fileserver based in procmail.
The file structure is as follows:
volume_1/
issue_1.txt
issue_2.txt
issue_3.txt
volume_2/
issue_1.txt
issue_2.txt
issue_3.txt
There are too many files to use symbolic links efficiently.
I was able to use the below modification of the common procmail
fileserver successfully, by using the exact path in the subject line (ie:
SEND ISSUE volume_1/issue_1.txt):
:0 c
* ^Subject: SEND ISSUE [0-9a-z]
* !^X-Loop: odn(_at_)main-net(_dot_)com
* !^Subject:.*Re:
* !^FROM_DAEMON
# * !^Subject: SEND ISSUE .*[/.]\.
{
MAILDIR=$HOME/webpgs/issues
:0 fhw
* ^Subject: SEND ISSUE \/[^ ]*
| formail -rA "X-Loop: odn(_at_)main-net(_dot_)com"
FILE="$MATCH"
:0 ah
| cat - ./$FILE 2>&1 | $SENDMAIL -oi -t
}
:0 a:
requests.log
(As a side note, despite having commented out 6th line of the recipe,
security appears to remain intact [I couldn't request files that were in
a higher directory than MAILDIR]. Although if I'm missing something, I'd
appreciate someone pointing it out.)
This works, but it's bulky. I'd like to be able to allow people, instead
of using:
SEND ISSUE volume_1/issue_1.txt
to be able to use:
SEND ISSUE 1-1
where the first number is the volume number, second number is the issue
number, all relating to the filenames.
I've been working on this for some time, trying a variety of variants,
but I can't seem to get it to work the way I want. I've tried one recipe
for all three volumes, and one recipe for each volume. Nothing seems to
work.
After posting a request to comp.mail.misc, era eriksson suggested I use
something like this:
: :0 c
: # * ^Subject: SEND ISSUE [0-9a-z]
: * ^Subject:\<*send\<*issue\<*\/[0-9]+-[0-9]+
: * !^X-Loop: odn(_at_)main-net(_dot_)com
: * !^Subject:.*Re:
: * !^FROM_DAEMON
: # * !^Subject: SEND ISSUE .*[/.]\.
: {
: MAILDIR=$HOME/webpgs/issues
: :0 fhw
: * ^Subject: SEND ISSUE \/[^ ]*
:
: | formail -I "From: odn(_at_)main-net(_dot_)com" -rA "X-Loop:
odn(_at_)main-net(_dot_)com"
:
: FILE="$MATCH"
:
: :0
: * STRING ?? -\/[0-9]+
: { ISSUE=$MATCH
:
: STRING=$MATCH
: :0
: * STRING ?? ^^\/[0-9]+
: { VOL=$MATCH }
:
: FILE=volume_$VOL/issue_$ISSUE.txt
:
: }
:
: :0 ah
: | cat - ./$FILE 2>&1 | $SENDMAIL -oi -t
: }
:
: :0 a:
: $HOME/requests.log
but it ends up just printing the results in the requests.log file. Here
are the various log outputs:
Verbose logging:
: procmail: [21011] Sun Sep 27 18:33:36 1998
: procmail: Assigning "LOGABSTRACT=on"
: procmail: Assigning "MATCH="
: procmail: Matched "1-1"
: procmail: Match on "^Subject:\<*send\<*issue\<*\/[0-9]+-[0-9]+"
: procmail: Match on ! "^X-Loop: odn(_at_)main-net(_dot_)com"
: procmail: Match on ! "^Subject:.*Re:"
: procmail: Match on ! "(^(Precedence:.*(junk|bulk|list)|To: Multiple
recipients of |(((Resent-)?(From|Sender)|X-Envelope-From):|>?From
)([^>]*[^((_dot_)%(_at_)a-z0-9])?(Post(ma?(st(e?r)?|n)|office)|(send)?Mail(er)?|daemon
|m(mdf|ajordomo)|n?uucp|LIST(SERV|proc)|NETSERV|o(wner|ps)|r(e(quest|sponse
)|oot)|b(ounce|bs\.smtp)|echo|mirror|s(erv(ices?|er)|mtp(error)?|ystem)|A(d
min(istrator)?|MMGR|utoanswer))(([^).!:a-z0-9][-_a-z0-9]*)?[%@>
][^<)]*(\(.*\).*)?)?$([^>]|$)))"
: procmail: Forking "procmail"
: procmail: [21012] Sun Sep 27 18:33:36 1998
: procmail: Assigning "MAILDIR=/home/odn/webpgs/issues"
: procmail: Assigning "MATCH="
: procmail: Matched "1-1"
: procmail: Match on "^Subject: SEND ISSUE \/[^ ]*"
: procmail: Executing "formail,-I,From: odn(_at_)main-net(_dot_)com,-rA,X-Loop:
odn(_at_)main-net(_dot_)com"
: procmail: Locking "/home/odn/requests.log.lock"
: procmail: Assigning "FILE=1-1"
: procmail: No match on "-\/[0-9]+"
: procmail: Locking "/home/odn/requests.log.lock"
: procmail: Assigning "LASTFOLDER=/home/odn/requests.log"
: procmail: Opening "/home/odn/requests.log"
: procmail: Acquiring kernel-lock
: procmail: Unlocking "/home/odn/requests.log.lock"
: From adamb(_at_)tezcat(_dot_)com Sun Sep 27 18:33:36 1998
: Subject: send issue 1-1
: Folder: /home/odn/requests.log 748
: procmail: Notified comsat: "odn(_at_)866:/home/odn/requests.log"
: procmail: Assigning "LASTFOLDER=/home/odn/requests.log"
: procmail: Opening "/home/odn/requests.log"
: procmail: Acquiring kernel-lock
: procmail: Unlocking "/home/odn/requests.log.lock"
: Subject: Re: send issue 1-1
: Folder: /home/odn/requests.log 250
: procmail: Notified comsat: "odn(_at_)1614:/home/odn/requests.log"
requests.log:
: From adamb(_at_)tezcat(_dot_)com Sun Sep 27 18:33:36 1998
: Received: from quilla.tezcat.com (root(_at_)quilla(_dot_)tezcat(_dot_)com
[204.128.247.10])
: by ra.mgmainnet.com (8.9.1/8.8.6) with ESMTP id SAA21009
: for <odn(_at_)main-net(_dot_)com>; Sun, 27 Sep 1998 18:33:35 -0400 (EDT)
: Received: from huitzilo.tezcat.com
(adamb(_at_)huitzilo(_dot_)tezcat(_dot_)com
[204.128.247.17])
: by quilla.tezcat.com (8.8.5/8.8.5/tezcat-96091001) with SMTP id
RAA18683
: for <odn(_at_)main-net(_dot_)com>; Sun, 27 Sep 1998 17:29:04 -0500 (CDT)
: Date: Sun, 27 Sep 1998 17:29:03 -0500 (CDT)
: From: Adam Bailey <adamb(_at_)tezcat(_dot_)com>
: To: Optical Data Network <odn(_at_)main-net(_dot_)com>
: Subject: send issue 1-1
: Message-ID:
<Pine(_dot_)SUN(_dot_)3(_dot_)95(_dot_)980927172850(_dot_)14096A-100000(_at_)huitzilo(_dot_)tezcat(_dot_)com>
: MIME-Version: 1.0
: Content-Type: TEXT/PLAIN; charset=US-ASCII
:
:
: To: adamb(_at_)tezcat(_dot_)com
: Subject: Re: send issue 1-1
: References:
<Pine(_dot_)SUN(_dot_)3(_dot_)95(_dot_)980927172850(_dot_)14096A-100000(_at_)huitzilo(_dot_)tezcat(_dot_)com>
: In-Reply-To:
<Pine(_dot_)SUN(_dot_)3(_dot_)95(_dot_)980927172850(_dot_)14096A-100000(_at_)huitzilo(_dot_)tezcat(_dot_)com>
: X-Loop: odn(_at_)main-net(_dot_)com
: From: odn(_at_)main-net(_dot_)com
Can anyone offer any suggestions? I'm not well-versed in procmail,
generally sticking to simple recipes. This is the most complex I've ever
had to deal with.
TIA!
--
Adam Bailey | Chicago, Illinois
adamb(_at_)tezcat(_dot_)com | "Logic is the art of going wrong with
adamkb(_at_)aol(_dot_)com | confidence." - George Bernard Shaw
Finger for PGP | http://www.tezcat.com/~adamb/