The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Mail command FeNiCrC_Neil UNIX for Dummies Questions & Answers 2 08-31-2007 01:12 PM
I am not able to send mail form unix to other mail accounts. chinnigd UNIX for Dummies Questions & Answers 1 04-06-2006 08:31 AM
UNIX mail command nbvcxzdz UNIX for Dummies Questions & Answers 1 12-20-2003 09:03 AM
E-Mail from command line for UNIX and Perl?? jy2728 Shell Programming and Scripting 4 11-26-2002 05:02 PM
can not send mail from unix server to company/yahoo mail b5fnpct UNIX for Dummies Questions & Answers 5 11-22-2002 09:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-15-2008
Shilpi Shilpi is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 5
Mail command in UNIX

1)My main script Calls a function IsDomain to check whether the domain is valid or not

PROD>/appl/retek/mpscripts/cat mg3TRn01
#!/bin/ksh
#
# Standard Header Files
#
#
. ${0%${0##*/}}UKMPFunctionLibrary.test
#
# START
#
ScriptStart
#
# Check that domain exists.Print & Commit the ASAP queue
#
IsDomain $SPDOM
ScriptEnd
#
# END
#

2) My global function library UKMPFunctionLibrary.test has the below functions defined

#
# Set Schedular Envronment Variables
#
. ${0%${0##*/}}UKMPEnv
THISFILE=${0##*/}
OVWFILE=$LOGS/mps_ovw.log
LOGFILE=$LOGS/$THISFILE.log.$(date "+%y%m%d%H%M%S")
TMPFILE=$TEMP/$THISFILE.tmp
WARNINGS=false
#
# Standrad log function
#
Log() {
case $2 in
0) LOGMSG=INFO;;
1) LOGMSG=WARNING;WARNINGS=true;;
2) LOGMSG=ERROR;;
*) echo $1 >>$LOGFILE; return;;
esac
echo $(date +"%T")' - '$LOGMSG' - '$1>>$LOGFILE;
echo $THISFILE' - '$(date +"%T")' - '$LOGMSG' - '$1
>>$OVWFILE
}
#
# Standard Mailing {Parameters 1 - Subject 2 - List of mail ids}
#
SendMail()
{
if [ $# -eq 2 ];then
echo " "|mail -s "$1" "$2";return $?
elif [ $# -eq 3 ];then
cat $3|mail -s "$1" "$2";return $?
else
return 2
fi
}
#
# Exit Codes {0 - Success; 1 - Warning; 2 - Failure}
#
Exit() {
case $1 in
0) Log 'END - SUCCESS' 0;exit 0;;
1) Log 'END - SUCCESS WITH WARNINGS' 1;exit 1;;
2) Log 'END - FAIL' 2;
MAILLIST="shilpi.sood@in.tesco.com";
SUBJECT="ALERT - The job $THISFILE has failed @
$(date)!Please Check";
SendMail "$SUBJECT" "$MAILLIST";
exit 2;;
*) Log 'END - ERROR' 2;exit 2;;
esac
}
#
# Standard Log File Heading
#
ScriptStart() {
echo $(date +"%Y%b%d")>>$OVWFILE
echo $(date +"%Y%b%d")>$LOGFILE
Log "START" 0
}
#
# Standard Log File End
#
ScriptEnd() {
Log 'END' 0
if [ $WARNINGS == 'true' ];then
Log 'SUCCESS WITH WARNING' 0;exit 0
else
Log 'SUCCESS' 0;exit 0
fi
}
#
# To check the existance of a domain {Parameter 1 - Domain
# Path}
#
IsDomain() {
checkDomain -d $1 -type simple>>$LOGFILE
if [ $? -ne 0 ];then
Log "Domain $1 does not exist" 2;Exit 2
fi
}

3) On failure the script is not returning the correct return code due to which we are facing issues.
In the global function Exit() can we not call the global function Sendmail()?
How can I edit the code so that the correct return code is passed from the script on failure?
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:57 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0