[TAG] question and announcement, sort of...

Robos robos at muon.de
Wed Jul 14 06:19:10 MSD 2004


On Tue, 13.07.04, Ben Okopnik <ben at callahans.org> wrote:

Hi Gang!

> > I recently had an idea: there are several "one word a day" mailing-lists
> > where you can learn new words in a language. So I thought to myself: how
> > about a "one command a day" for all my linux newbie friends? I asked several
> > people and they liked the idea, so this thing is now rolling for the 3rd
> > week. I think that maybe an announcement in linuxgazette is reaching a wider
> > audience. But there is one problem though: the text is in german! But I
> > think nevertheless I can reach quite some people this way, germans or
> > german-speaking (hi Ben, wanna practise? ;-).
> 
> Oh, man. I wish I had the time to spare. These days, I don't. :(

Okay, reading german is a little less fun that a HALO jump :)

> > Old posts and at the same time the log is here:
> > http://vobcopy.org/cgi-bin/blosxom/one-cmd-a-day/index.html
> > BUT when I get lots of people I need an automatic emailing-system.
> > At the moment there are 2 groups of people. One is further in the "list of
> > commands" than the other. So I need to write a new explanation for the
> > advanced group, write their email-addressment (hi list, this command is
> > about bla whereas that of yesterday dealt with blubb, but here it comes),
> > address the email, attach the explanation (is in separate command.txt every
> > time) and send it away. Then I go into my sent-mail folder, find the
> > corresponding email to send to the lagging group, change the recipients and
> > maybe correct the addressment and send it away.
> > Can you help me automate this? So that it is expandable? I am a lousy
> > bash-programmer and my solution would be fairly ugly. If some of the perl
> > gurus could help me here, I'd be thankful!
> 
> Well, seems like setting up Mailman or another list manager would be the
> answer - lots of flex for later expansion. However, here's a pretty
> simple script that should do what you're asking:
> 
> ----------------------------------------------------------------------
> #!/bin/bash
> # Created by Ben Okopnik on Tue Jul 13 11:45:09 EDT 2004
> 
> [ -z "$2" ] && { printf "Usage: ${0##*/} <list> <file> [file] ... \n"; exit; }
> 
> files=`echo "$@"|sed 's/^[^ ]* //'`
> 
> for n in `cat $1`; do cat $files|mail -s 'Command-a-day' $n; done
> ----------------------------------------------------------------------
> 
> You'll need a list containing the email addresses, one per line or space
> separated, that you want to send it to (just the foo at bar.com ones, not the
> longer versions), the "state of the union" message you want to send (lets
> call it "comments.txt"), and your command.txt file. Given the above, you'd
> run it like this:
> 
> cmd_a_day list.txt comments.txt command.txt
> 
> You'd need to run it twice, with the appropriate values for all of the
> above parameters for your two lists. Note that you could mix and match more
> stuff by adding more files at the end of the list; the concatenated result
> is what will be sent to the specified list.

Hmm, I see I didn't make myself clear enough: there are 2 groups
_at_the_moment_ but I would like the skript to be so flexible that it can
handle incoming new persons or groups and see to it that all get the
follow-up command to their previous mail.
I would do something like:
-a list with all the recipients
-a list where the current "command position" for each recipient is noted and
incremented
-a list with all the commands.

Since I am a lousy programmer I would work with ed here, something like this
pseudo-code:

email-list.txt:
bla at com
blubb at de
spam at yahoo
morespam at hotmail

command-nr.txt:
2
3
1
6

commands.txt:
ls
man
less
more
id
yes

------------pseudo-code------------
declare -i i; i=0
for recipient in $(cat email.txt)
do
nr=(corresponding nr in command-nr.txt, stepping through the file with ed
probably, dunno how else)
mail $recipient
cat $(with nr see in commands.txt which comments.txt to load, a la "email-ls.txt")
attach $(with nr see in commands.txt which command.txt to load, a la "ls.txt")
------------/pseudo-code------------

The generation of the commands.txt and corresponding comments.txt file could
also be automated, but I think I know how to do that.

Now clearer?
Nevertheless, thanks Ben :)
Cheers List
Robos


-- 
Robos - 
gpg --recv-keys --keyserver blackhole.pca.dfn.de 6EEADA09
It's GNU/Linux dammit! F U M $ !




More information about the TAG mailing list