Listing 1 send_email
##################################################
# KSH Function: send_email
# Author : Rainer Raab (raabrr@yahoo.com)
# Date : 11/28/2000
##################################################
# Description : Sends an e-mail message to a
# list of recipients. The message body contains
# the hostname and timestamp. Lowercase letters
# are automatically converted to uppercase, to
# allow for readability on text pagers.
##################################################
# Usage:
# EMAIL_LIST="email_address1 email_address2 ..."
# EMAIL_SUBJECT="Subject"
# EMAIL_MESSAGE="Message body"
##################################################
function send_email {
for EMAIL in $EMAIL_LIST; do
SYSTIME=$(date '+%m-%d-%y %H:%M')
SYSHOST=$(hostname)
SUBJECT=$(printf "$EMAIL_SUBJECT"|tr "[:lower:]" "[:upper:]")
printf "$SYSHOST MSG ($SYSTIME): $EMAIL_MESSAGE\n"|tr "[:lower:]" \
"[:upper:]"|mailx -s " $SUBJECT" $EMAIL
done
}
|