Guest User

Untitled

a guest
Nov 7th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. clear
  2. MONTH=$(date -d "$D" '+%m') # Get the numerical month
  3. YEAR=$(date -d "$D" '+%y') # Get the 2-digit year
  4. MONTH=$((MONTH-1)) # Reduce the month value by one as I am working with the previous month
  5. DATSET=$YEAR-$MONTH # This is used in the directory and file name
  6. echo "This script will email the telephone accounts for $DATSET. Please wait." # Gotta say something to inform the user about what is going on...
  7. BASEDIR="/home/Groups/ICT/TMS" # Location of Telephone account directories
  8. THISDIR="/home/Groups/ICT/scripts" # Where the recipient contact csv file resides
  9. AFSUB=$(date --date='-1 month' +'Telefoon rekeninge vir %b %Y') #Subject line for Afrikaans recipients
  10. ENSUB=$(date --date='-1 month' +'Telephone accounts for %b %Y') # Subject line for English recipients
  11. INPUT=contact.csv # Database of recipients
  12. OLDIFS=$IFS
  13. IFS=,
  14. [ ! -f $THISDIR/$INPUT ] && { echo "$INPUT file not found"; exit 99; }
  15. while read department email firstname language # Read the contact file into an array
  16. do
  17. if [ "$language" != "af" ]
  18. then
  19. if [ "$department" = "Finance" ]
  20. then
  21. 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
  22. else
  23. 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
  24. fi # Send the message in English if the language setting is not af, add additional attachment if department is finance
  25. else
  26. if [ "$department" = "Finance" ]
  27. then
  28. 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
  29. else
  30. 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
  31. fi # Send the message in Afrikaans, add additional attachment if the department is finance.
  32. fi
  33. sleep 10
  34. done < $INPUT
  35. IFS=$OLDIFS
  36. exit
Add Comment
Please, Sign In to add comment