Mailx command issue

Hi All,

Im facing a problem with sending tar file via mailx command. Your help would be much appreciated.

Im trying to tar a set of CSV files in a folder using the below command

tar cvf Report.tar.gz *_03172016.CSV

and sending this tar file using mailx command as mentioned below

ux2dos Report.tar.gz | uuencode Report.tar.gz | mailx -m -s "UAT Report" "abc@hotmail.com"

The problem here is, if all the CSV files are of size 0 byte, the tar file contains all the 0byte CSV files in the email attachment.

If any of the file size greater than zero, then the attachment contains files until a non zero byte file is encountered in the alphatebetically sorted list.

PS : i tried to ftp the tar file manually to windows and chkd it, and in both cases, all the CSV s files were present in the tar.

I know its confusing..:mad: I've attached the email and the manually ftp'ed tar file for your ref

Looks like smethg is goin wrong in the mailx command.

Kindly share your inputs to fix the issue.

Also let me know if there are any other ways to zip and send all the CSV files as email attachment.

tar cvf does nut produce tar.gz files, for that you need tar zcvf if your tar supports that, or use gzip separately to gzip the tar file..
ux2dos only makes sense on unix style text files, not tar files or gz files..

1 Like

Thx @Scrutinizer. it works perfectly fine with ur solution. There is one more problem with mailx command. the email body.

Either the attachment is missing or the email body is missing. I tried the below two commands.

Code 1:

mail_bdy=`echo "Hi All,

PFA the UAT Report for ${CUR_DATE}.

Thank You."`
echo "$mail_bdy"|uuencode UAT_Report_${CUR_DATE}.zip UAT_Report_${CUR_DATE}.zip | mailx -m -s "TESTING - UAT Report ${sub_date}" XXX@gmail.com

Code 2:

uuencode UAT_Report_${CUR_DATE}.zip UAT_Report_${CUR_DATE}.zip | mailx -m -s "TESTING - UAT Report ${sub_date}" XXX@gmail.com << EOM

Hi All,

PFA the UAT Report for ${CUR_DATE}.

Thank You."

EOM

Please advise.