mailx -s not sending the file to mail address


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting mailx -s not sending the file to mail address
# 1  
Old 05-21-2010
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:

Code:
#!/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,

Last edited by Scott; 05-21-2010 at 12:11 PM.. Reason: Code tags, please...
# 2  
Old 05-21-2010
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.
# 3  
Old 05-21-2010
yes there are some failures when I use "mail" command..
# 4  
Old 05-21-2010
Quote:
Originally Posted by a1_win
Hi All,

OS:Red Hat Linux 4 86x64

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

Code:
#!/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

NoteSmilieerf_report.sql generates a spool file -> *MONTHLY*REPORT*.lst

What's wrong in the above script?

Thanks for your time in helping!

Regards,

Change this line and let retry

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

and
if file list in this path
Code:
ls <path_to_the_script/*MONTHLY*REPORT*.lst > /<path_to_the_script/ perf_report.out

or content data
no change Smilie
Code:
cat <path_to_the_script/*MONTHLY*REPORT*.lst > /<path_to_the_script/ perf_report.out

# 5  
Old 05-21-2010
What do they suggest ?.. May be some DNS issue or the receipt id does not exists something like that?.
# 6  
Old 05-21-2010
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,
# 7  
Old 05-21-2010
Code:
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...

Last edited by curleb; 05-21-2010 at 04:38 PM.. Reason: fine print...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

Problems sending mail: Difference between Mail and Mailx?

Whats the difference between mail and mailx? I'm trying to troubleshoot a problem where I can send mail from server A with this `echo $MESSAGE | mail -s "$SUBJECT" -r $FROM $RECIPIENTS` command but executing the same command from server B throws me this error (Both servers are RHEL) ... (1 Reply)
Discussion started by: RedSpyder
1 Replies

2. UNIX for Dummies Questions & Answers

Mailx working but not sending mail

Hi All, I have a unix server on which mailx is configured . Earlier i was getting proper mails but now some mails are getting stuck and i am not receiving the emails from the server. I can see the mails in mailq. Can you please help me with this . How can i receive these emails? (2 Replies)
Discussion started by: pratikm23
2 Replies

3. Shell Programming and Scripting

How to embed a html file in a mail sending from Linux box with uuencode or mailx?

How to embed a html file as subject in a mail sending from Linux box with uuencode or mailx or any other way? we do not want the file as attachment, it should be embedded in the mail subject. (2 Replies)
Discussion started by: johnveslin
2 Replies

4. Shell Programming and Scripting

sending mail through mailx command

Hi I need help to send mail through mailx command . Currenlt my program is like #!/bin/ksh -x echo " " >> path.lst MAIL_LIST='someone1@gamil.com someone2@gamil.com someone3@gamil.com' cat path.lst | mailx -s "path loaction" $MAIL_LIST echo "End" exit 0 Its work fine . But i... (3 Replies)
Discussion started by: mani_isha
3 Replies

5. Shell Programming and Scripting

sending mail using Mailx with data from oracle table

Hi, i need to send emails to the mail ids i receive using the sql query . SELECT L.ALARM_DEF,L.CRITERIA,L.DISTANCE_METRE,L.EMAIL,L.LAC_ID,L.LAST_CHECK,L.RANGE, L.RESOURCE_MSISDN,LM.ADDRESS,LM.NAME FROM LANDMARK_ALARM_CONF l, LANDMARK lm WHERE L.LANDMARK_ID=LM.LANDMARK_ID AND... (0 Replies)
Discussion started by: aemunathan
0 Replies

6. Shell Programming and Scripting

sending mail from perl using mailx

hi All, i am trying to send a mail from perl using mailx. the script runs fine if i hard code the file path which is to be attached to the mail. but when i give a variable containing the path of the file , perl is not able to send the file. ex: system('uuencode /attach/test.txt... (3 Replies)
Discussion started by: adityamahi
3 Replies

7. UNIX for Dummies Questions & Answers

sending mail using mailx command

Hi All, Please help me regarding sending mails using mailx command in unix. I will be glad if some one give me the sintax of this. I tried using the below but vain. mailx -s 'Hi' 'xyz@abc.com' Regards, Manas (5 Replies)
Discussion started by: manas6
5 Replies

8. Shell Programming and Scripting

how to know if the mailx command really sends the mail to the email address?

Hi guys, I have a question about the returning message of the mailx command. if I run a mailx command, how can I know if the email has been sent to the email address? If the email address doesn't exist, is there any error message returned? If yes, how can I get the error message? Thanks... (3 Replies)
Discussion started by: sheenshine
3 Replies

9. Shell Programming and Scripting

sending mail through mailx

while trying to send a mail, though the output file doesn't contain any exclamatory mark(!), i am getting that in the mail with an extra line. please help me out from this ASAP. (3 Replies)
Discussion started by: pvamsikr
3 Replies

10. HP-UX

Sending Error msg from HP-UX to E-mail address

Sometimes, for any reason, the UX System sends messages to /var/mail/root and/or to Error Log of the guardian. I'll appreciating if you help me to configure so that those messages are also sent to the System Administrator's e-mail address. Regards Gege (1 Reply)
Discussion started by: cgege
1 Replies
Login or Register to Ask a Question