Reputation: 24154
I am sending an email by using below commands by combining all the output and sending in one email. It works fine for me.
mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r [email protected] [email protected] <<EOF
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`
Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`
Error Percentage: $QUERY2
EOF
Now I need to attach one file within the above email and that file is under temp folder
with the name of chart
. And while sending I need to send it as chart.html
file.
So How can I modify my above command so that it can attach chart
as chart.html file
from temp folder
in the email.
Hope I am clear to everyone. I am running SunOS
.
Any suggestions will be appreciated.
Updates:-
If I need to add uuencode command in my shell script so it should be like below? or something else
mailx -s "LIP Data Quality Report for $DATE_YEST_FORMAT1" -r [email protected] [email protected] <<EOF
uuencode /tmp/chart chart.html
Data Successfully loaded into LIP_DATA_QUALITY table
Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`
Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`
Error Percentage: $QUERY2
EOF
Upvotes: 0
Views: 1309
Reputation: 19375
The least necessary change to your shell script would be
`uuencode /tmp/chart chart.html`
(the backticks to have the command substitution of uuencode inserted in the here document).
Upvotes: 0
Reputation: 8587
apt-get install sharutils
where run.sh
is the attachment and hello
is the message
(echo "hello" ; uuencode run.sh run.sh ) | mailx -s "Testing 2" root@localhost
EMAILCONTENT="Data Successfully loaded into LIP_DATA_QUALITY table \n Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`\n Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`\n Error Percentage: $QUERY2 \n"
(echo $MAILCONTENT ; uuencode /tmp/chart chart.html ) | mailx -s "Testing 2" root@localhost
### OR
FILE="/tmp/email.content"
echo -e "Data Successfully loaded into LIP_DATA_QUALITY table \n Total Items Purchased: `echo $QUERY1 | awk '{print $1}'`\n Total Items MissingorMismatch: `echo $QUERY1 | awk '{print $2}'`\n Error Percentage: $QUERY2 \n" > $FILE
(cat $FILE ; uuencode /tmp/chart chart.html ) | mailx -s "Testing 2" root@localhost
Upvotes: 1
Reputation: 4384
you can use a more versatile mail user agent like email
from http://www.cleancode.org/projects/email which natively manages attachements
Upvotes: 0