getting xargs and mail to play nicely

Lennart Sorensen lsorense-1wCw9BSqJbv44Nm34jS7GywD8/FfD2ys at public.gmane.org
Wed Jun 15 13:14:24 UTC 2005


On Tue, Jun 14, 2005 at 10:57:43PM -0400, Peter King wrote:
> I want to do a (legitimate!) mailing of a single message to several
> recipients, and I'd like each to be the sole recipient specified in
> the email -- so no multiple addresses, cc, bcc, or suchlike. I have
> the recipients' addresses in a single text file, with one address per
> line in the file.
> 
> How can I do a "mass mailing"?
> 
> Why xargs, I thought, just grep through the address file and feed it
> to mail, and redirect the message:
> 
>     % grep @ addressfile | xargs -n1 mail -s SUBJECT < messagefile
> 
> But this doesn't work: mail tries to take addresses from messagefile,
> not from addressfile. If I leave off the messagefile, then I send nice
> cheerful null emails to each person listed in addressfile.
> 
> What am I missing here? Sorry to be clueless!

when you do a | b < c

where is stdin for b coming from?  a or c?  you wanted mail to use c as
stdin, but that's not what bash does.  bash gives it to the command
(xargs in this case) that it follows apparently overriding the fact you
are trying to pipe something to stdin.

Lennart Sorensen
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list