Visit Our UNIX and Linux User Community


Unable to attache file in mailx


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Unable to attache file in mailx
# 1  
Old 10-19-2009
Question Unable to attache file in mailx

I have script to send report to the recipent along with a short decription of a message. But unfortunatly it fails to deliver the report as attachment nothing apart from the message come,
please find the part where I am getting stuck and confused ... please check out if you have any better suggestion to it.

below is the part where it should attach the file and send it but it fails to do.

please advice.
Code:
#---------------------------------------------------------------------#
#       Checking for the number of SAL016 reports
#---------------------------------------------------------------------#

if [ $count -eq 0 ]
then
        MESSAGE="Hi,\n\nThere are no SAL016 reports for ${name} in today's run test. \n\nThanks,\nWMG IT Operations"
        echo "$MESSAGE" | mailx -s "${name} SAL016 reports for the run date of `date +%d-%b-%Y`" peter.tom@test.com
        exit 1
fi

if [ $count -lt 2 ]
then
        MESSAGE="Hi,\n\nOnly one SAL016 report generated for ${name} in today's run test1. \n\nThanks,\nWMG IT Operations"
        echo "$MESSAGE" | mailx -s "${name} SAL016 reports for the run date of `date +%d-%b-%Y`" peter.tom@test.com
        exit 1
fi

ux2dos $report1 > $report1.txt
ux2dos $report2 > $report2.txt

#---------------------------------------------------------------------#
#       Sending a mail with SAL016 reports
#---------------------------------------------------------------------#

MESSAGE="Hi,\n\nPlease find the attached ${name} SAL016 Reports.\n\nThanks,\nWMG IT Operations"
$(echo "$MESSAGE"; uuencode $report1.txt ${name}_SAL016_Report1.txt; uuencode $report2.txt ${name}_SAL016_Report2.txt) | mailx -s "${name} SAL016 reports for
 the run date of `date +%d-%b-%Y`" peter.tom@test.com


Last edited by pludi; 10-19-2009 at 05:35 PM.. Reason: code tags, please...
# 2  
Old 10-19-2009
instead of
Code:
$(echo "$MESSAGE"; uuencode.......

use
Code:
(echo "$MESSAGE"; uuencode.......

at the start of the last line

Previous Thread | Next Thread
Test Your Knowledge in Computers #514
Difficulty: Easy
As a general rule, the more a variable is used, the longer the variable name should be.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to attach a .txt file or .log file to mail and mailx command

Hi, I am trying to attach a .log file or .txt file to mail command to send an email once my ksh script executed. I am unable to use mutt command as it has been not installed and i am not supposed to install it. I have tried many ways by googling which has not helped me to succeed. Here is my... (5 Replies)
Discussion started by: Samah
5 Replies

2. UNIX for Dummies Questions & Answers

Unable to send attachment using mailx command

I am unable to send email with attachment using the mailx command. Without the attachment, the email goes through file. This is the command I use. Works : $ echo "Test" | mailx -s "Test" username@website.com Fails : $echo "Test" | mailx -a all-dss-accounts.txt -s "Test"... (3 Replies)
Discussion started by: nkarthik_mnnit
3 Replies

3. Shell Programming and Scripting

[Solved] Unable to mailx new $pid for a script restart

Ill try to make this brief: I am trying to get the script below to run another script defined as BATNAM. The script runs fine, does what i designed it to do, however... I would like it to mailx the NEW $pid that was restarted. This script is supposed to go in crontab as root, and run by... (8 Replies)
Discussion started by: olyanderson
8 Replies

4. Solaris

Unable to send mail through mailx

Hi, I am using solaris 5.9 OS and I am facing an issues with mailx. My SMTP port is configured to listen 6190 and not the default one which is 25. I can send mail to my inbox when i do it manually through the following steps root@<dbname> # telnet 15.12.88.10 6190 Trying 15.12.88.10...... (0 Replies)
Discussion started by: Srinathkiru
0 Replies

5. Linux

mailx: Unable to send Japanese

Hi All, I am facing problem in sending Japanese characters using mailx command in GNU linux machine. The mail is going with junk characters like "メールの-界へようこそ". I tried changing the LANG value to japan locale off UTF-8. But it doesn't worked. I have to send the data as body not as an... (0 Replies)
Discussion started by: Karteek
0 Replies

6. Shell Programming and Scripting

unable to put cc list in mailx

Hi, I am using mailx command to send mail. But unable to use -c option to send mails by cc list. eg. ..mailx -s "subject" -c "CCLIST" "TOLIST" Its showing " illegal option -- c" I am using HP UX. Can anybody help me out. Thanks in advance..! (3 Replies)
Discussion started by: Kattoor
3 Replies

7. UNIX for Dummies Questions & Answers

Unable to send e-mail using mailx command

Hi All, Can you please help me in solving this. I am facing some problem sending mails. If I use like this, I am able to send mail the mail echo "This is an automated e-mail; please do not reply." | mailx -s "Good Morning ." 'abc@xys.com' But if I use like this, then I am unable to send... (1 Reply)
Discussion started by: manas6
1 Replies

8. UNIX for Advanced & Expert Users

unable to sent mail in html format by mailx command.

I use maix command to sent mails. i can sent only plain text mails. Unable to sent mails in html format. while sending mails in html format, the received mail has the html code only. (17 Replies)
Discussion started by: p_prathaban
17 Replies

9. Shell Programming and Scripting

UNABLE to send 5MB attachment using mailx

hi, i've created a script that sends out an email using the mailx and uuencode command. the script is ok, but when a 5MB attachment is sent, there are time that the intended recepients does not receive any email. i tested it and the issue is intermitent. please help on how to troubleshoot. i... (3 Replies)
Discussion started by: tads98
3 Replies

10. Shell Programming and Scripting

unable to do mailx from shell script

Hi From within a shell script my mailx doesnt seem to work...can somebody tell me what is wrong... #!/bin/ksh #Script to verify wheather all databases listed are up and running #Script works with Oracle8 and above databases #Script has to be run by ./scriptname DBA=xiamin@unix.com echo... (3 Replies)
Discussion started by: xiamin
3 Replies

Featured Tech Videos