procmail
[Top] [All Lists]

Re: procmail and ifile

2002-08-20 05:40:14
in message <005e01c24838$9d4af920$2d320a0a(_at_)s14cit>,
wrote lk thusly...

I'm trying to include ifile (for spam filtering) into procmail,
but have no success. When trying my setup from command line, it
works. But when used in .procmailrc, return code is always 1. Why?

please do wrap lines around 69 or so characters.

rest of the reply deals w/ the shell scripting, not the question at
hand.


Iin .procmailrc I have:

:0w
* ? dm
spam

Script dm:

#!/bin/sh
if [ `/usr/local/bin/ifile -q -v 0 | /usr/bin/head -1 | /usr/bin/awk '{print
$1}'` = "spam" ]; then
        exit 0
else
        exit 1
fi

i almost missed the back-quotes.  if "$()" construct had been used
instead, i wouldn't have to re-read 4-5 times just to reconcile the
interaction between "[" (test) & the external commands.

that could be re-written for better readability, imo, (assuming grep
is the gnu version which w/ -q option will obviate the need of "head")...

  #!/bin/sh

  #  set PATH to wherever "ifile" & "grep" can be found
  PATH=/usr/bin:/usr/local/bin

  #  both if statements are equivalent afaik
  #if  ifile -q -v 0 | grep -q '^spam'
  if { ifile -q -v 0 | grep -q '^spam' ; }
  then
    exit 0
  else
    exit 1
  fi

...or, in other words...

  #!/bin/sh
  PATH=/usr/bin:/usr/local/bin

  { ifile -q -v 0 | grep -q '^spam' ; }  &&  exit 0
  exit 1


-- 

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