procmail
[Top] [All Lists]

Re: Cannot Find sed in Recipe

1997-07-17 16:42:00
On Thu, 17 Jul 1997, David W. Tamkin wrote (excerpted):

[I had in a recipe:]
|     NL="
| "
|     :0 w
|     | sed -e "1,$/, /$NL/g" $USERLIST | egrep -is $WHOFROM $USERLIST

Bad sed command, Paul: to put a literal newline into a replacement string,
you need to precede it with a backslash (if strong-quoted; two backslashes
if weak-quoted as you have there, so that one survives the shell).

    Thanks for that bit of information.  I fully admit that I really
don't know much about Un*x utilities and haven't had the chance to
learn.  The man pages can sometimes be a little obscure as learning
materials (more reference refreshers, I would say).  So I appreciate
people taking time to give me a hand.

| procmail: Executing " sed -e "1,$/, /$NL/g" $USERLIST | egrep -is $WHOFROM 
$USERLIST"
| sed: Unknown command

See; sed is saying "sed: unknown command"; procmail is not saying
"procmail: sed: unknown command" nor "procmail: cannot execute sed."

    OK.  Somehow I had the mistaken idea that all entries in the
procmail log were put there by procmail itself and therefoe were
referring to procmail's activity.

[I'm also curious about that pipe to egrep; you're specifying a search file
("$USERLIST") on the command line but also feeding egrep some stdin?]

| sed -e "1,$/, /$NL/g" $USERLIST | egrep -is $WHOFROM $USERLIST

    Which, for refreshment, was as above.  Actually, I was copying 
all this straight out of someone else's response from a bit ago.  I
supposed (apparently mistakenly) that he knew more than I did about 
the matter.  I have straightened out the sed portion, but the recipe 
still will not work in this form.  (I just have gotten rid of sed
complaining.)

    I have a file, pointed to by $USERLIST, in the format

user1(_at_)domain1, user2(_at_)domain2, user3(_at_)domain3, ...

The recipe is working so far to get the trimmed-down (i.e.,
user(_at_)domain) sender's address into the variable $WHOFROM.  Now I want
to see if the value of $WHOFROM is contained in the file pointed to by
$USERLIST. If yes, take one action.  If no, take another.  (These are
subrecipes headed by :0a and :0E with nesting blocks.)

    Somebody suggesting using sed to create a temporary file with each
userN(_at_)domainN on its own line and grepping that.  I can see why the
overall line above beginning with sed cannot work, because that
temporary output file is not getting fed into egrep properly.  I just
now realized that. :(  What is happening now according to the log is
that procmail is stripping off the vertical bar on the recipe line
above and assigning the whole rest of the line to LASTFOLDER, and
everything folds up.

Paul                             <pobart(_at_)access(_dot_)digex(_dot_)net>
----------------------------------------------------------
Paul O. Bartlett, P.O. Box 857, Vienna, VA 22183-0857, USA
Finger, keyserver, or WWW for PGP 2.6.2 public key
Home Page:  http://www.access.digex.net/~pobart

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