All,
I'm having difficulty using a variable as the body of an e-mail; I suspect it has to do w/quoting, but am not sure. Right now I have separate functions for sending information and for sending errors. I'd like to set a variable (BODY) to use as input to mailx so I can have a generic function to send mail from my script. The code in the send_event_request function works fine; I can use it to send mail, but can't seem to find a way to use the BODY variable. Also, I'm having problems getting the newlines to work in BODY. (Note: All other variables are set elsewhere in the script and work fine.)
Thanks in advance!
BODY="Please run Event $EVENT (${DC}CAHOLD) for the $UL_TIME Upload. Thanks!\n\n"
BODY=$BODY"Stats For $UL_FILE\n"
BODY=$BODY"----------------------\n"
BODY=$BODY"Records : $LINE_COUNT\n\n"
BODY=$BODY"Started : $START_TIME\n"
BODY=$BODY"Finished : $FINISH_TIME\n\n"
BODY=$BODY"*** NOTE ***\n"
BODY=$BODY"This is not a production script.\n"
BODY=$BODY"A production script would have been e-mailed to the ollowing users:\n"
BODY=$BODY"$CURRENT_USERS\n\n"
BODY=$BODY"-----------------------------------------------------------------------------------------\n"
BODY=$BODY"This e-mail was automatically generated by $SCRIPT_NAME on $HOST_NAME. Please do not reply."
send_event_request()
{
echo "Sending e-mail request..."
SUBJECT="TEST"
TO="me@mydomain.com"
`mailx -s "$SUBJECT" "$TO" <<-EOF #$BODY would go here
Please run Event $EVENT (${DC}CAHOLD) for the $UL_TIME Upload. Thanks!
Stats For $UL_FILE
----------------------
Records : $LINE_COUNT
Started : $START_TIME
Finished : $FINISH_TIME
*** NOTE ***
This is not a production script.
-----------------------------------------------------------------------------------------
This e-mail was automatically generated by $SCRIPT_NAME on $HOST_NAME. Please do not reply.`
~. 2>/dev/null
EOF 2>/dev/null
}