1

I want to send multiple CSV file using below code. In Result folder, we have multiple CSV files. However, I want to catch only Summary CSV files. I was trying using *, % with different combination. However, not able to do so.

From below code, I could send only one file (SDN_WCFINCEN_summary_20151013_111216.csv )

(cat /aceapp/QATD011R4/ace.ofac/testofac/results/SDN_WCFINCEN_summary_20151013_111216.csv;
uuencode /aceapp/QATD011R4/ace.ofac/testofac/results/SDN_WCFINCEN_summary_20151013_111216.csv SDN_WCFINCEN_summary_20151013_111216.csv) | mail -s "Summary Report" smawle@acesw.com
  • 1
    uuencode can't handle multiple file, moreover, uuencode a b will encode a with b as a name, you have to do a loop. – Archemar Oct 14 '15 at 13:13
1

As Archemar says, you need a loop. For example:

(BTW, add as many files as you like to the FILES variable, separated by spaces)

FILES="/aceapp/QATD011R4/ace.ofac/testofac/results/SDN_WCFINCEN_summary_20151013_111216.csv"

(for f in $FILES ; do uuencode "$f" "$f" ; done ) | mail -s "Summary Report" smawle@acesw.com

If you want to strip the path from the filename output by uuencode, replace the second "$f" in the uuencode command with $(basename "$f")

  • Why are you looping over a single value? – Wildcard Dec 16 '16 at 6:35
  • @Wildcard the OP says to add the list of files to $FILES. The example is of only one file though – roaima Dec 16 '16 at 8:01
  • If the OP hadn't specified uuencode, I would preferred to use a tool like mime-construct or makemime or write a trivial script using one of the perl or python MIME mail generating modules. BTW, looking at my answer again, if I could have assumed bash rather than sh, I would have used an array for FILES rather than a string. and to make a more useful script, maybe extracted the date/time from the .csv filename and added that to the Subject: header (either with bash string manipulation features or with sed) - but only if sending only one file at a time. – cas Dec 16 '16 at 10:04
  • @Wildcard why? read the second, parenthetical, paragraph of my answer and then read the question again. – cas Dec 16 '16 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.