Nithin
February 20, 2010, 12:20am
1
Hi All,
Currently i am using below script to attach excel and email from a Unix script.
uuencode ASC.xls|mailx -m -s "ABCD_subject`TZ=CST+24 date +%d-%b-%y`" email@email.com
Can anyone give me or help me in zipping excel and sending that email as the excel is very heavy.
Thanks,
Scott
February 20, 2010, 12:21am
2
gzip -c ASC.xls | uuencode ASC.xml.gz | mailx .....
Nithin
February 20, 2010, 12:50am
3
Thanks Much!!!
Please suggest on how to write body for the email above.
Scott
February 20, 2010, 1:06am
4
I normally use something like:
cat << ! | mailx ......
Message body goes here
$(gzip -c ASC.xls | uuencode ASC.xls.gz)
!
Nithin
February 20, 2010, 1:23am
5
echo "Hi All" >> cnt
echo "" >> cnt
echo "" >> cnt
cat cnt | gzip -c ASC.xls | uuencode .........
I am using the above format but i am getting attchment but not the body in the email"HI ALL".
Scott
February 20, 2010, 12:09pm
6
All you've done here is compress your file cnt into a file called ASC.xls and sent that as an attachment. "HI ALL" is in the attachment!
That's not quite how I described it.
Nithin
February 20, 2010, 1:34pm
7
cat << ! | mailx ......
Message body goes here
$(gzip -c ASC.xls | uuencode ASC.xls.gz)
!
Hi could you please describe the above code whats the (!) in the code ?
Scott
February 20, 2010, 1:50pm
8
It's just a "word" that marks the start, and end of a "here-document". It could be pretty much anything you like.
<<[-]word The shell input is read up to a line that is the same as word after any quoting has been removed,
or to an end-of-file. No parameter substitution, command substitution, arithmetic substitution
or file name generation is performed on word. The resulting document, called a here-document,
becomes the standard input.
By convention, people often use either ! or EOF as "word"
cat << EOF | mailx ......
Message body goes here
$(gzip -c ASC.xls | uuencode ASC.xls.gz)
EOF
is the same thing.
The XLS file is encoded inside the here-document, and sent as an attachment in the mail.
Nithin
February 20, 2010, 1:53pm
9
can i keep the code given by you inside a shell script ???
because i am exporting the excel file using one more sql query...all these command are there in a shell script
Nithin
February 20, 2010, 2:00pm
11
auto_repconnect auto_sql auto_status 1>>auto_suc.xls 2>>auto_err
gzip -c auto_suc.xls | uuencode auto_suc.xml.gz |mailx -m -s "Subject" abc@xyz.com
this is inside a shell script(.sh) file
need to get msg body as well as attchment. tried several ways but failing.
Look at mpack instead of uuencode & mailx.
It's very easy to use and you can send any attachments you want.
Scott
February 21, 2010, 6:05am
14
nithin:
auto_repconnect auto_sql auto_status 1>>auto_suc.xls 2>>auto_err
gzip -c auto_suc.xls | uuencode auto_suc.xml.gz |mailx -m -s "Subject" abc@xyz.com
this is inside a shell script(.sh) file
need to get msg body as well as attchment. tried several ways but failing.
Why are you using this code, instead of the code I showed you?
Nithin
February 21, 2010, 6:16am
15
this is my original code.. which gives me excel attached zipped. i just want to add body to this code.