procmail
[Top] [All Lists]

Denis Roegel's $FOUND

1997-10-03 09:42:15
When Denis Roegel asked,

R>  now, suppose I want to call `myprogram' with parameter $FOUND,
R>  and get the result back in RESULT, how do I do it ?

Philip Guenther answered,

G>      :0
G>      * FOUND ?? .
G>      RESULT=| myprogram $FOUND

G> The stdout of myprogram will be captured at stored in the variable
G> RESULT.

If myprogram doesn't read any stdin from the message, an `i' flag will
help there; otherwise procmail will complain that not all of the message
text was accepted as stdin.

Ed Sabol answered Denis's question this way:

S> Change the recipe to:

S>    :0:
S>    * FOUND ?? .
S>    { RESULT = `myprogram $FOUND` }

That will avoid any complaints about myprogram's not reading the message, but
you'll get an extraneous local lockfile error.

Another matter to consider is what should happen if there are spaces or tabs
in the value of $FOUND.  Perhaps it should be 

   RESULT=| myprogram "$FOUND" # in Philip's suggestion, or
   { RESULT = `myprogram "$FOUND" } # in Ed's

That might be especially important if, for some reason, $FOUND contains only
spaces.  Alternatively, you could change the condition to require that $FOUND
have at least one character that is not a space, a tab, nor a newline:

  * FOUND ?? [^         ]

The brackets enclose a caret, a space, and a tab.

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