Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clear
- MONTH=$(date -d "$D" '+%m') # Get the numerical month
- YEAR=$(date -d "$D" '+%y') # Get the 2-digit year
- MONTH=$((MONTH-1)) # Reduce the month value by one as I am working with the previous month
- DATSET=$YEAR-$MONTH # This is used in the directory and file name
- echo "This script will email the telephone accounts for $DATSET. Please wait." # Gotta say something to inform the user about what is going on...
- BASEDIR="/home/Groups/ICT/TMS" # Location of Telephone account directories
- THISDIR="/home/Groups/ICT/scripts" # Where the recipient contact csv file resides
- AFSUB=$(date --date='-1 month' +'Telefoon rekeninge vir %b %Y') #Subject line for Afrikaans recipients
- ENSUB=$(date --date='-1 month' +'Telephone accounts for %b %Y') # Subject line for English recipients
- INPUT=contact.csv # Database of recipients
- OLDIFS=$IFS
- IFS=,
- [ ! -f $THISDIR/$INPUT ] && { echo "$INPUT file not found"; exit 99; }
- while read department email firstname language # Read the contact file into an array
- do
- if [ "$language" != "af" ]
- then
- if [ "$department" = "Finance" ]
- then
- echo -e "Good day $firstnamennnPlease see attached accounts for $departmentnnnICT" | mail -r dummyuser@dummydomain.dom -s $ENSUB -A $BASEDIR/$DATSET/$DATSET-$department.pdf -A $BASEDIR/$DATSET/$DATSET-Summary.PDF -A $BASEDIR/$DATSET/$DATSET-Detailed.PDF $email@dummydomain.dom
- else
- echo -e "Good day $firstnamennnPlease see attached accounts for $departmentnnnICT" | mail -r dummyuser@dummydomain.dom -s $ENSUB -A$BASEDIR/$DATSET/$DATSET-$department.pdf -A $BASEDIR/$DATSET/$DATSET-Summary.PDF $email@dummydomain.dom
- fi # Send the message in English if the language setting is not af, add additional attachment if department is finance
- else
- if [ "$department" = "Finance" ]
- then
- echo -e "Goeie dag $firstnamennnSien asb aangehegte rekeninge vir $departmentnnnICT" | mail -r dummyuser@dummydomain.dom -s $AFSUB -A $BASEDIR/$DATSET/$DATSET-$department.pdf -A $BASEDIR/$DATSET/$DATSET-Summary.PDF -A $BASEDIR/$DATSET/$DATSET-Detailed.PDF $email@dummydomain.dom
- else
- echo -e "Goeie dag $firstnamennnSien asb aangehegte rekeninge vir $departmentnnnICT" | mail -r dummyuser@dummydomain.dom -s $AFSUB -A$BASEDIR/$DATSET/$DATSET-$department.pdf -A $BASEDIR/$DATSET/$DATSET-Summary.PDF $email@dummydomain.dom
- fi # Send the message in Afrikaans, add additional attachment if the department is finance.
- fi
- sleep 10
- done < $INPUT
- IFS=$OLDIFS
- exit
Add Comment
Please, Sign In to add comment