On Fri, 16 Oct 1998 09:32:56 -0400, "'Bennett Todd'" <bet(_at_)mordor(_dot_)net>
1998-10-16-07:49:39 Eric, Audet:
I think I do not understand your script ...If someone could translate
that in perl OR explain me the program
What I can see is that you use sendmail sending to all addrss ... but
what is the $(_at_)? the message?
tmp=/tmp/`basename $0`.$$; trap "rm -rf $tmp" 0
Two commands. First, set the internal shell variable "tmp" to something like
"/tmp/helper-script.948"; we built it up from "/tmp/", the output of the
basename command run on argv (to strip off any leading directory path from
the command name), and "$$" which shell expands into the PID of the current
shell process. The second command "trap" sets an on-exit hook (that's trap 0;
trap for larger numbers sets signal handlers). This will delete the tmp
directory on exit.
What's the purpose of using a directory? Shouldn't there be a trap for
when the script is ctrl-c:ed or hupped in the middle, too?
(echo '#!/bin/sh';echo '/usr/lib/sendmail "$@" <'$tmp/message) >$tmp/sender
Create a second tmp file, which is a shell script to invoke
sendmail with stding redirected from the message; after executing
this command there will be a script named something like
"/tmp/helper-script.948/sender", containing something like:
/usr/lib/sendmail "$@" </tmp/helper-script.948.message
Such a script, when invoked, will send a copy of the message (that was saved
using the "cat" command above) to all the recipients listed on its command
Are you sure this is necessary? (If yes, why not store the script in a
here document? Anything to avoid an explicit temp file :-)
xargs $tmp/sender <addrss.txt
Invoke the sender script for all the addresses listed in
addrss.txt, in batches long enough to be pretty efficient, but not
so long as to bang against shell or OS command-line length limits.
Clever, but how about just
trap 'rm -f $TMP; exit 1' 1 2 3 15
while read address; do
/usr/lib/sendmail -oi "$address" <$TMP
rm -f $TMP
Yeah, it won't send to multiple recipients, but like we have been
saying, you should be using a real mailing list manager if you want it
to be nice and pretty (on the outside :-)
BTW, I have a web page about the ARG_MAX issue which might clarify the
original question. <http://www.iki.fi/~era/unix/arg_max.html>
/* era */
You could of course make the script read more than one address at a
time. For the truly desperate, here's a one-liner which takes a file
of one address per line and spits out 25 at a time:
sed -e 'N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;N;s/\n/ /g'
You have to take out the quotes around "$address" and make sure the
input doesn't contain spaces or other funnies.
Bot Bait: It shouldn't even matter whether (`') Just (`') http://www.iki
I am a resident of the State of Washington \/ Married! \/ .fi/~era/