I have a problem. I need to write a script that will find any file generated 1 day ago And then email it to certain mail-address from Tuesday to Sunday at 2 am?
The problem is my script finds the 3 correct files but either sends 3 different emails with single attachment or send 1 email without any attachment. How can I edit it to send multiple attachments in 1 email? It seems every file needs a 'uuencode' with it, so tried concating "uuencode" to the "filename" and then add that variable to the command of ssmpt. Neither of the 2 version are really working.
How can I write the regular experession so that all the files found is emailed using 1 email. My current script just sends email with no attachment at all or 1 file per email.
Please help.
Here is what my script looks like:
Version 1: sends 1 email with no attachment:
#!/bin/bash
dt=$(date --date yesterday "+%Y-%m-%d")
result="performance-team*-$dt.txt"
arr=()
arr=($(find /root/Desktop/fileNAme -type f -name "${result}"))
for i in "${arr[@]}"
do
value=" uuencode -e $i $(basename $i);"
valueTotal=$valueTotal$value;
done
echo -e "to:email@email.com\nSubject:performance of teams on ${dt};"|(cat - && ${valueTotal};)|/usr/sbin/ssmtp email@email.com
Version 2: sends 3 email with single attachment in each:
#!/bin/bash
dt=$(date --date yesterday "+%Y-%m-%d")
result="performance-team*-$dt.txt"
arr=()
arr=($(find /root/Desktop/fileNAme -type f -name "${result}"))
Count=0
for i in "${arr[@]}"
do
Count=$((Count+1))
echo -e "to:email@email.com\nSubject:performance of teams on ${dt}; mail ${Count} of 3\n"|(cat - && uuencode $i;)|/usr/sbin/ssmtp to:email@email.com
done
tar
to combine the files you find, and thenuuencode
the resulting tarfile? – MikeA Oct 18 '16 at 19:36mutt
available? – thrig Oct 18 '16 at 20:12