procmail
[Top] [All Lists]

Re: Input of an extracted field value to a script

2001-08-19 02:02:52
Harsha Vardhana R <hvardhan(_at_)cisco(_dot_)com> writes:
I need to extract a word from 'Subject' field and and pass it on to a script
for further processing.
I am extracting the first word in the 'Subject' field.

My $HOME/.procmailrc contents are

SHELL=/bin/sh
PATH=/bin:/usr/bin:/usr/local/packages/procmail/procmail-3.11pre7/bin

This is probably better written as

        PATH=/usr/local/packages/procmail/procmail-3.11pre7/bin:$PATH
or
        PATH=$PATH:/usr/local/packages/procmail/procmail-3.11pre7/bin

depending on whether the procmail package directory should override
other items in the path.


STRING=`formail -zxSubject:` #(get the subject field)
S1=`echo $STRING | cut -f1 -d ' '` #(Extract the first word)

Frist of all, why didn't you combine those into a single command?

        S1 = `formail -zxSubject: | cut -f1 -d ' '`

However, procmail's match operator would be _much_ more efficient:

        :0
        * ^Subject: *\/[^ ]+
        { S1 = $MATCH }


No external commands needed.


:0:
* ^From.*hvardhan
* ^Subject:.Status
| $HOME/ProcTrial/ProcessString "$S1"
...
procmail: Couldn't determine implicit lockfile from 
"/users/hvardhan/ProcTrial/ProcessString"
procmail: Locking ".lock"

Is it a problem is more than one copy of the script was run at once?
If not, then you don't need the locallockfile and should remove the
second colon from the ":0" line.

If you do need a lockfile, you should explicitly specify its name.  As is,
procmail doesn't have enough information to associate the action with
a file being changed, so it uses ".lock" as the name of the lockfile.
To quote the procmail(1) manpage:
       Couldn't determine implicit lockfile from "x"
                              There were no `>>'  redirectors  to
                              be  found,  using simply `$LOCKEXT'
                              as locallockfile.


procmail: Error while writing to "/users/hvardhan/ProcTrial/ProcessString"

Does your ProcessString script read its stdin?  By defaul, procmail
assumes that if a program is supposed to handle the delivery of a message
that it'll read in the entire message.  If your script doesn't do that
then you should put the 'i' on the recipe.  To quote the procmailrc(5)
manpage:
       i    Ignore  any write errors on this recipe (i.e. usually
            due to an early closed pipe).


Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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