![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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? |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|