mailx -s not sending the file to mail address

Hi All,

OS:Red Hat Linux 4 86x64

Below is my shell script which is not sending mail to the mail recipient:

#!/bin/bash
export MAILLIST="xyz@yahoo.com"
cd <path_to_the_script_perf_report.sql>
sqlplus / as sysdba @perf_report.sql
if [ `cat /<path_to_the_script/*MONTHLY*REPORT*.lst|wc -l` -gt 0 ]
then
  cat <path_to_the_script/*MONTHLY*REPORT*.lst > /<path_to_the_script/ perf_report.out
  mailx -s "Perf Report Output" $MAILLIST < /<path_to_the_script/ perf_report.out
fi

Note:perf_report.sql generates a spool file -> *MONTHLY*REPORT*.lst

What's wrong in the above script?

Thanks for your time in helping!

Regards,

Please use code tags to format the post.

Are you getting any error while running the script?

if no is answer to the above question , then check your system mail box using "mail" command to see , whether there are any failures.

yes there are some failures when I use "mail" command..

Change this line and let retry

if [ `ls -1 /<path_to_the_script/*MONTHLY*REPORT*.lst|wc -l` -gt 0 ]

and
if file list in this path

ls <path_to_the_script/*MONTHLY*REPORT*.lst > /<path_to_the_script/ perf_report.out

or content data
no change :slight_smile:

cat <path_to_the_script/*MONTHLY*REPORT*.lst > /<path_to_the_script/ perf_report.out

What do they suggest ?.. May be some DNS issue or the receipt id does not exists something like that?.

It's working and sending mail when I use ls -l and ls as pointed out by user 'ygemici' but not working with cat.

But my purpose is to send the contents of the file using cat and ls -l or ls will send only the path name to the file and file name.

Please advise!

Thanks,

---------- Post updated at 11:37 AM ---------- Previous update was at 11:35 AM ----------

Could anyone pls suggest alternatively, How could I send spool file as attachment in the mail.

Thanks,

function mailme 
{ 
#  set -x 
   #  This function will forward any local file as an e-mail attachment... 
   #     -> currently only provides a text-formatted attachment. 
   FILE="${1}" 
   ATTACHMENT="${1##*/}" 
   TO="${2:-foo@bar.com}" 
   SUBJECT="MailMe: ${FILE}" 

   if    [[ -z ${FILE} ]] \
      || [[ -z ${ATTACHMENT} ]] 
   then 
      echo "MailMe needs a file to attach..." 
      exit 
   fi 

   print "Mailing: ${ATTACHMENT}... " 2>/dev/null 
   uuencode ${FILE} ${ATTACHMENT} |mailx -s "${SUBJECT}" ${TO} 

   return 
}

Oh, hey...one big caveat with the aforementioned function...it makes no effort to either size the attachment file, or even possibly compress it before mailing. You might want to make sure it wouldn't try to forward something so large it would choke the mail server.

just a thought...