On 11/5/2011 3:02 PM, Anton Aylward wrote:
Rodney Baker said the following on 11/05/2011 10:31 AM:
What you have is a fragment of a script - this is not a complete shell script.
I told him that when I sent it to him bask on 10/16/2001
I'd suggest you read a) the metasend man page, to understand what the above fragment is doing,
I suggested that to him as well. Man pages are an important part of comprehension. If you don't read and understand them you are unlikely to understand how to use the command.
and b) a tuturial on shell scripting for your preferred shell (be it bash, zsh, csh or whatever)
And I suggested that as well.
I don't think that I can point to the file from within the script,
You can, I showed him how.
as if the mail list file was stored on the computer in a different file.
I told him that as well, I even suggested the format, address followed by names
I explained that the above was the 'inner loop' and that he needed something external to it that did:
cat addressfile | while read DEST REALNAME do ...
The ${XXXX} are names of variables that you have to define at the beginning of the script. For example:
I told home that too, and explained and illustrated just as you have done but rather more ...
DEST="some-recipient@some-server.domain" SUBJECT="Monthly Newsletter" FROM="you@your.isp.domain" TEXTFILE="/path/to/textfile" PDFFILE="/path/to/pdffile"
Actually I suggested
------------------------------ #! /bin/sh
cd $HOME/SkiMailManagement
ADDRESSFILE=${ADDRESSFILE-skipatrolemailaddresslist} SUBJECT=${SUBJECT-"Newsletter for $(date %B %Y)"} FROM=${FROM-"munguanaweza@embarqmail.com"}
TEXTFILE=${TEXTFILE-./newsletters/$(date %Y/%b).txt} PDFFILE=${PDFFILE-./newsletters/$(date %Y/%b).pdf}
You can see that there are few assumptions. First, that this is a directory of its own where the address list and other stuff live. Second that there is a subdirectory with the newsletters. Third, that they are "by month". Fourth that they are available both as text and PDF.
OOPS! Not everyone does that, eh? So the TEXTFILE should be set to a plain text file that says "Please see the attached PDF file".
Having things set like this with the shell variables allows for this flexibility.
An easier way would be to source a file with a list of all the email addresses, then parse that file one line at a time in a conditional loop until you reach EOF, updating DEST and re-running the above fragment until the last email has been sent.
That depends on whether you see the fragment as being all of the script or having the 'while' in the script.
The lists I maintain this for it is inside the script.
Shell scripting isn't that hard once you've played with it a few times. There are plenty of good online resources that google will turn up for you but some are better than others - YMMV.
I think his real problem is that he doesn't get shell scripting and variables.
Once upon a time UNIX ran in less than 56K so there was more reliance on scripts as opposed to binaries. That's where I leant, machines that had lots and lots of scripts to do what we do with binaries these days. Much more 'visibility'.
I also suggested he read http://www.shelldorado.com/scripts/cmds/sendfile which is a much simpler but well scripted example of using metasend.
I wish I'd read this before I went and spent all the time writing my last post! headsmak. -- bkw -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org