E-mail mechanism in ShellScript.
Hi,
I have writeen two scripts which will e-mail the output to the respective ids.
One script is as below:
echo "$SERVERNAME" > /home/xmuser/MiddlewareNotification/Util/SingleNodeStatus/SingleNodeStatus.
echo "Server Down " >> /home/xmuser/MiddlewareNotification/Util/SingleNodeStatus/SingleNodeStatus.txt
subject="$SERVERNAME Server($IP) is down on `date` "
emailcontent='/home/xmuser/MiddlewareNotification/Util/SingleNodeStatus/NodeStatusEmailContent.txt'
echo "Subject: ${subject}" > ${emailcontent}
cat /home/xmuser/MiddlewareNotification/Util/SingleNodeStatus/SingleNodeStatus.txt>> ${emailcontent}
/usr/sbin/sendmail -f $sender_email $receiver_email < ${emailcontent}
It is working fine and we are getting the mails.
But the e-mail part of second script is as below:
ErrorLogFile=`echo $1|sed 's/.* @#@#//'|awk -F@#@# '{print $4}'|sed 's/ .*//'`
EMAIL_LIST=`echo $1|sed 's/.* @#@#//'|awk -F@#@# '{print $1}'|sed 's/ .*//'`
InterfaceName=`echo $1|sed 's/.* @#@#//'|awk -F@#@# '{print $2}'|sed 's/ .*//'`
SUBJECT="File Transfer Status - $InterfaceName >>Successful, Environment >> $2 "
ERROR_FILE_TEXT=`cat /home/xmuser/MiddlewareNotification/$ErrorLogFile`
if [ -n "$EMAIL_LIST" ]
then
for MAIL_TO in $EMAIL_LIST
do
BODY="File Transfer Status - $FILE_TRANSFER_STATUS"
BOUNDARY='=== This is the boundary between parts of the message. ==='
{
print - "From: Middleware Account<tpdamrki@wgchost>"
print - "To: $EMAIL_LIST"
print - 'Subject:' $SUBJECT
print - 'MIME-Version: 1.0'
print - 'Content-Type: MULTIPART/MIXED; '
print - ' BOUNDARY='\"$BOUNDARY\"
print -
print - ' This message is in MIME format. But if you can see this,'
print - ' you aren't using a MIME aware mail program. You shouldn't '
print - ' have too many problems because this message is entirely in'
print - ' ASCII and is designed to be somewhat readable with old '
print - ' mail software.'
print -
print - "--${BOUNDARY}"
print - 'Content-Type: TEXT/PLAIN; charset=US-ASCII'
print -
#echo $BODY
#if [ -z "$ERROR_EXISTS" ] && [ $InterfaceName = 'EDI832_Inbound_Interface' ]
#then
#echo "File tranferred successfully for $InterfaceName at `date +"%Y.%m.%d.%H:%M:%S"`"
#else
cat /home/xmuser/MiddlewareNotification/$ErrorLogFile
#fi
print -
print -
print - "--${BOUNDARY}"
print - 'Content-Type: TEXT/PLAIN; charset=US-ASCII; name='None
print - 'Content-Disposition: attachment; filename='
print -
print -
print - "--${BOUNDARY}--"
} | /usr/sbin/sendmail $MAIL_TO
done
fi
The abobve script is throwing error as below:
----- The following addresses had permanent fatal errors -----
<Debasish.Mishra@tcs.com>
(reason: 553 #5.1.8 Domain of sender address <xmuser@wgcwebsphere03.wearguard-crest.com> does not exist)
----- Transcript of session follows -----
... while talking to inmumg01.tcs.com.:
>>> MAIL From:<xmuser@wgcwebsphere03.wearguard-crest.com> SIZE=1738
<<< 553 #5.1.8 Domain of sender address <xmuser@wgcwebsphere03.wearguard-crest.com> does not exist
501 5.6.0 Data format error
Both the scripts are on same server,how I am getting the domain error?Can anyone please advice?
Thanks in advance
|