Email not being sent from shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Email not being sent from shell script
# 1  
Old 06-17-2011
Email not being sent from shell script

Hi All,

I have prepared the below shell script but no email is being sent from the shell script.Not sure what's wrong here:
Code:
echo $SHELL
/bin/bash

Code:
. $HOME/.profile
. /home/oracle/Oracle_xyz.env

export log=/orabin/Oracle/rman_Oracle_arch.out

rman target / @/home/oracle/rman/rman_oracle_arch.sql $log

export status=$?

export DBALIST="xyz@abc.com"


if [ $status -gt 0 ] ; then
 mailx -s "RMAN Archivelog BACKUP FAILED: Oracle" $DBALIST << cat $log
else
 mailx -s "RMAN Archivelog Backup Successful: Oracle" $DBALIST << cat $log
fi

Could anyone please let me know wjhy the above script is not sending mails once RMAN backup completes successfully or not

Thanks for your time!

Regards,
a1_win

Last edited by Scott; 06-17-2011 at 04:57 PM.. Reason: Code tags, please...
# 2  
Old 06-17-2011
I have never seen << used for input redirection...but for here document only
# 3  
Old 06-17-2011
You have to configure mailx. How to do that, strongly depends on your system. So, what system are you on?
Next, try to send an email from CL:
Code:
echo testBody | mailx -s testSubject me@myaddress.com

Next, this redirection looks funky:
Code:

<< cat $log

Correct syntax would be:
Code:
cat $log | mailx -s subject $address

or better yet, without useless cat:
Code:
mailx -s subject $address < $log

# 4  
Old 06-17-2011
try:
Code:
if [ $status -gt 0 ] ; then
 cat $log | mailx -s "RMAN Archivelog BACKUP FAILED: Oracle" $DBALIST 
else
 cat $log | mailx -s "RMAN Archivelog Backup Successful: Oracle" $DBALIST

# 5  
Old 06-17-2011
Email not being sent from shell script

Thanks all for your time!

This is resolved after removing << and making single <

Regards,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sending email in shell script

Can anyone help me out how to send the email without the word success while sending to the recipient. echo "success" | mailx -s "webshell instance has been started noiw" implementation@tkcl.com (8 Replies)
Discussion started by: ramkumar15
8 Replies

2. UNIX for Dummies Questions & Answers

Shell script to email logfile

Hi, I am trying to write a shell script to send a log file of a query run in oracle.Pls help me I am very new to shell scripting. echo " Checking Activity Spec " sqlplus / as sysdba <<END_SQL @activity_spec_metadata.sql quit;>>logfile END_SQL mailx -s "Checking Activity Spec schedule... (1 Reply)
Discussion started by: Rossdba
1 Replies

3. Shell Programming and Scripting

Email Attachments in shell script

Hi Fellas, I have a script that queries a sybase DB through isql and appends to a file, say file.csv I want to use the mail command in the shell script to email the file to me. i tried the following command but it doesn't work. can any one suggest whats wrong here. Note that i need the file... (2 Replies)
Discussion started by: Irishboy24
2 Replies

4. Shell Programming and Scripting

Help with shell script to send email once

Hi Guys, I have this script which will monitor oracle db process if up or down.And I want it to send email if it's down and the time it's back to online. However my script just keep on sending "Email Up" if the db is up or "Email Down" if the db is down.Is there any way to trap it so that it... (5 Replies)
Discussion started by: d3xt3r
5 Replies

5. Shell Programming and Scripting

Help with Email Status shell script

I have written a bash script to to sort the data from logs i need some help in printing the outputs , i dont have much ideas in bah scripting. Sample script ----------------------- #!/bin/bash a=`date | cut -d " " -f2,2,3` cat /var/log/maillog |grep "$a" |grep -E -e 'deferred|bounced'... (9 Replies)
Discussion started by: unimaxlin
9 Replies

6. Shell Programming and Scripting

Sending email from shell script

Hi, I need to send email from a shell script. i echoed some information to a file and i am doing cat command in the email syntax thanks (2 Replies)
Discussion started by: rocky1954
2 Replies

7. Shell Programming and Scripting

How to send email through shell script

Hi All, I am new to the unix , i have to deliver one script very urgently I have to write a shell script where i have i want to send email to specific email id in this script i want FROM to be parameterized and stored in a variable TO to be parameterized and stored in a variable... (3 Replies)
Discussion started by: nileshbhawsar
3 Replies

8. Shell Programming and Scripting

EMail Address Validation (Shell Script)

Hi, Can anyone provide me the code snippet for EMail Address Validation. User is going to enter the email address in form window. I need to validate the format is correct. Thanks in Advance BS (3 Replies)
Discussion started by: balajiora
3 Replies

9. UNIX for Dummies Questions & Answers

Email sending through a shell script

Hi everyone, I have a shell script that I use to send some emails with attachments. Based on the attachment file that is being sent, I choose the recipient. My file_list.txt looks like this CAJ.txt;sm@email.com KXLD.txt;jc@email.com I do a grep on this file to look for the file name and... (3 Replies)
Discussion started by: memonks
3 Replies

10. Shell Programming and Scripting

Sending attachments using email through shell script

Hi all, I have written a shell script which sends emails with attachments to our clients. All our attachments are simple flat files (.txt format). The script is working fine and sending the attachments to the mail-ids except that, when i am sending the attachments to non-outlook users (Like... (6 Replies)
Discussion started by: symhonian
6 Replies
Login or Register to Ask a Question