Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

selective mailx from a namelist file 1

Status
Not open for further replies.

hubud

Instructor
Oct 18, 2002
123
GB
I've stumbled over a little problem. Most of my scripts email confirmation of success or failure. I do this by having a namelist file with a list of addresses to mail.
Because a fair few scripts run now I am started to collect far too many namelist files.
I figure if I can selectively choose from this list then I can put all names in one file and let the script decide.

I do it as follows:

while read namelist
do
mailx $namelist<<-EOF

TEXT TO SEND

Datamart Support
EOF
done<$namelist

This method only allows me to send to an entire file of names.
I thought a case statement that identifies addresses and sends mail, or not, depending on the name.
Problem is, how do I exit from that iteration of the loop but continue with the rest? An &quot;exit&quot; statment will exit the loop and script as well so that's no good.

does anyone have any ideas


cheers

simmo
 
break

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Read the man page for break. You probably want continue instead of exit.

Greg.


 
Cheers for that folks,

I've gone along the lines of a case statement as follows:

while read namelist
do

case $namelist in

Blue) ;;
*)
mailx $namelist<<-EOF

Mail text

EOF;;
esac
done<$namelist

It will send mail to anyone other than &quot;Blue&quot;, or that's the theory. I keep getting the following error:

syntax error at line 71 : `<<' unmatched

Any ideas?

cheers

simmo
 
mailx $namelist<<-EOF

Mail text

EOF
;;


Jean Pierre.
 
cheers jp,
Just found that out by experimentation.

cheers

simmo
 
I would suggest a different way - without the while loop or the case...

mailx `grep -v &quot;Blue&quot; $namelist` <<-EOF

Mail text

EOF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top