LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-01-2007, 10:11 AM   #1
151803
LQ Newbie
 
Registered: Jan 2007
Posts: 22

Rep: Reputation: 15
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
 
Old 11-01-2007, 10:17 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
I don't know if this is the case, but once I got the same error when I did not specify the sender address with the -f option to sendmail. You did in the first script, not in the second one. Eventually you can give it a try.
 
Old 11-01-2007, 10:23 AM   #3
151803
LQ Newbie
 
Registered: Jan 2007
Posts: 22

Original Poster
Rep: Reputation: 15
Email mechanism in shell script

The second script is working fine when I am giving the mail id (to which the mail needs to be sent) within server network.But when I am giving the mail id outside the network(outside the firewall of that network)it is not working.
But,the first script is working fine with both the above cases.Can anyone please tell me what for is that -f option?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Shellscript paraiso Linux - Newbie 7 05-12-2005 07:25 AM
shellScript help paraiso Linux - Newbie 2 05-10-2005 07:09 PM
LS and shellscript - I'm stuck MikeHunt79 Linux - Software 2 03-11-2005 04:44 AM
ShellScript sharadgana Programming 1 12-16-2004 01:16 PM
how to execute mail command in a shellscript mema Programming 1 10-30-2003 02:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration