procmail
[Top] [All Lists]

Re: Host lookups

2008-11-28 07:33:14
On Fri, Nov 28, 2008 at 02:14:38AM -0500, Fleet Teachout wrote:

I'm trying to use procmail to do the host lookup so I 
can see the "Remote Name."  So far I have:

:0
* ^Return-Path: <fleet(_at_)core(_dot_)mynewhost(_dot_)com>
* ^Subject: Journal hit
   {
     :0 cB
     * Remote = \/.*
     | XXX=`host $MATCH | cut -d' ' -f5`

     LOG="$XXX
     "

     :0
     results
   }

Everything works until I get to the | XXX line.  Nothing gets assigned to 
XXX.  MATCH shows in the log as - procmail: Matched "75.104.35.214" for  
example.

Log shows:

I already know it will be empty as to XXX.  You are using wrong
syntax.  Suggest you do a quick review of the man page.


  |      Starts the specified program, possibly in $SHELL if any  of  the
         characters  $SHELLMETAS are spotted.  You can optionally prepend
         this pipe symbol with variable=, which will cause stdout of  the
         program  to  be  captured  in the environment variable (procmail
         will not terminate processing the rcfile at this point).

Try

    XXX=| host "$MATCH" | cut -d' ' -f5

And you would not need the c-flag at the start of the recipe.

However, there is a serious bug in many procmail binaries making
the above syntax unsafe.  Random memory will be eaten unless you
have applied a patch.  So the alternative below is recommended:

  :0
  * conditions
  { XXX = `shell command` }

(You don't need the c-flag there, either.  Nested brace sets
are not delivering recipes, and the assignment therein is also
not a delivering action.)

I believe the latter is what you were attempting all along anyway.


By the way, can't you just turn on the reverse-lookup feature in
your SMTP host's setup?

Dallman
____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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