procmail
[Top] [All Lists]

Re: Input of an extracted field value to a script

2001-08-17 11:43:52
* Harsha Vardhana R <hvardhan(_at_)cisco(_dot_)com> [010817 11:05]:
Hello,

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
MAILDIR=$HOME/Mail
LOGFILE=$HOME/ProcTrial/proc_log
VERBOSE=yes

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

:0:
* ^From.*hvardhan
* ^Subject:.Status
| $HOME/ProcTrial/ProcessString "$S1"

But it is not working in the intended way

My procmail log file contents are

procmail: [10233] Fri Aug 17 10:11:24 2001
procmail: Executing "formail,-zxSubject:"
procmail: [10233] Fri Aug 17 10:11:28 2001
procmail: Assigning "STRING=StatusReport  Important  20Aug2001"
procmail: [10233] Fri Aug 17 10:11:29 2001
procmail: Executing "echo $STRING | cut -f1 -d ' '"
procmail: [10233] Fri Aug 17 10:11:29 2001
procmail: Assigning "S1=StatusReport"
procmail: [10233] Fri Aug 17 10:11:40 2001
procmail: Match on "^From.*hvardhan"
procmail: Match on "^Subject:.Status"
procmail: Couldn't determine implicit lockfile from
"/users/hvardhan/ProcTrial/ProcessString"
procmail: Locking ".lock"
procmail: [10233] Fri Aug 17 10:11:43 2001
procmail: Executing "/users/hvardhan/ProcTrial/ProcessString,StatusReport"
procmail: [10233] Fri Aug 17 10:11:48 2001
procmail: Error while writing to "/users/hvardhan/ProcTrial/ProcessString"
procmail: Assigning "LASTFOLDER=/users/hvardhan/ProcTrial/ProcessString
StatusReport"
procmail: Unlocking ".lock"

What are the causes for the error here? Are there any special rules
regarding running scripts ?

Looks like something is going wrong w/ your script "ProcessString".
Check the permissions on it.  Is it executable?  I usually invoke
scripts like this:

| $PERL perlscript.pl
| $PYTHON pythonscript.py
etc

You could make the script more compact (and perhaps more efficient) by
writing it like this:

:0:
* ^From.*hvardhan
* ^Subject:.Status
{
    S1=`formail -zxSubject: | cut -f1 -d ' '` 
    :0
    | $HOME/ProcTrial/ProcessString "$S1"
}

Won't fix the script error though.

-- 
- Matt Dunford <> zoot(_at_)zotikos(_dot_)com ..
-. www.zotikos.com -- o,;-
        
Today's `fortune`:
A limerick packs laughs anatomical
Into space that is quite economical.
        But the good ones I've seen
        So seldom are clean,
And the clean ones so seldom are comical.
--
_______________________________________________
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>