Mailing an attachment

Hi,

I need to compress (zip) a flat file and mail the same as an attachment.
I had tried the following piece of code. But when i open the attachment in mail, the data is incorrect (displays all junk characters).

tar cf abc.tar abc.txt
compress abc.tar
uuencode abc.tar.Z abc1.wri | mailx -s "Audit report" xxxx@rediffmail.com

Note: I have already created a file abc.txt.

Thanks.

Please make sure that you have read our rules. And note:
(4) Do not 'bump up' questions if they are not answered promptly. No duplicate or cross-posting and do not report a post where your goal is to get an answer more quickly.

I have closed your duplicate thread.

Since you are using compress, what did you expect? It changes the file into a compressed data block file. Unless you are uncompressing it, the file probably looks the same as it does on the system you mailed it from. Compare the two files (the attachment and the compressed file on the original server).

Note, even tar may change the file where it will not be readable. Also, a tar file may not be viewable on some other servers.

An since it it appears that you are only dealing with one file why are you bothering to tar it?

zip abc.zip abc.txt
uuencode abc.zip abc.zip | mailx -s "Audit report" xxxx@rediffmail.com

Thanks for the help.
That was really useful.

Sorry perderabo for cross posting.
I will not repeat the same.