procmail
[Top] [All Lists]

Re: Cannot Find sed in Recipe

1997-07-17 16:44:00
Paul Bartlett continued,

|     OK.  Somehow I had the mistaken idea that all entries in the
| procmail log were put there by procmail itself

... they are, in a sense, because sed's error messages are going through
procmail's handling into the logfile ...

| ... and therefoe were referring to procmail's activity.

Ah, no.

When procmail forks sed, sed inherits its parent's (procmail's) file
descriptors.  It can change them, but any that it doesn't change point
where the parent pointed them.

Once you define a LOGFILE, procmail points file descriptor 2, generally
used for error messages and other user warnings, into the logfile.  Thus,
error messages from programs that are run by procmail (or by shells that
procmail invokes) go to the logfile as well unless the program (or the shell
or the program) directs them somewhere else.

| > [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.)

egrep is going to ignore stdin, I'm sure, if you name a text file on its
command line, so pretty much sed is doing its work for nothing.

|     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.

|     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.

There is no temporary file; sed's output becomes egrep's input, which egrep
ignores because its command line tells it to read input from a file instead.

If you take the trailing "$USERLIST" out of egrep's command line arguments,
egrep will read sed's output from the pipe.

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