0

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
2

3 Answers 3

1
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
Sign up to request clarification or add additional context in comments.

2 Comments

I just upated my question with the way I am using uuencode command is right or not? Any thoughts will be appreciated.
nope that is incorrect since you are carrying out the uuencode withing a string called EOF that you are passing to it the correct way would be : (as above new content added to this post)
0

you can use a more versatile mail user agent like email from http://www.cleancode.org/projects/email which natively manages attachements

Comments

0

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.