Help...anyone...
I want to craft a .procmailrc rule like:
get the Subject line and parse it into a FILENAME to be used to
log emails each containing a single line of data
Write that single line of data to $FILENAME
SHELL=/usr/bin/ksh
:0 c
* ^Subject: XXXXXX
* ^From:(_dot_)*something(_at_)domain(_dot_)com(_dot_)*
# other filters here?
|export FILENAME=`formail -xSubject: |sed -e 's/ //g'`
:0 A
# formail -I "" gets just the body, the sed stuff strips blank lines:
|formail -I "" | sed -e '/^$/ d' >> /path/log/${FILENAME}
where FILENAME would be determined from Subject field via:
FILENAME=`formail -xSubject: |sed -e 's/ //g'`
(yeah...some red flags here security-wise, but I can deal with that later...
hopefully with better sed expressions)
and the body of the message would be appended to $FILENAME via:
formail -I "" | sed -e '/^$/ d' >> /path/log/${FILENAME}
Problem is that above doesn't work...seems the second filter doesn't
get the value of $FILENAME passed?
FYI...if I use:
:0 c
* ^Subject: XXXXXX
* ^From:(_dot_)*something(_at_)domain(_dot_)com(_dot_)*
# other filters here?
| (export FILENAME=`formail -xSubject: |sed -e 's/ //g'` ; \
echo "${FILENAME}" > /path/log/out1)
:0 A
# formail -I "" gets just the body, the sed stuff strips blank lines:
|(echo "${FILENAME}" > /path/log/out2 ; \
formail -I "" | sed -e '/^$/ d' >> /path/log/foo)
I end up with:
-rw------- 1 dwm dwm 24 Oct 28 16:55 foo <- data - good!
-rw------- 1 dwm dwm 7 Oct 28 16:55 out1 <- XXXXXX - good!
-rw------- 1 dwm dwm 1 Oct 28 16:55 out2 <-blank - not good
anyone with clues to offer??
Thanks
Doug Monroe
Lucent Technologies