Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- #This script uses awk to find all successful"err=0" queries and
- #prints the previous line (getline) for $LOGS |
- #then greps for the word "BIND" | then grep -v excludes unwanted queries |
- #then uses sed to ONLY get the uid name after uid= and before ou= |
- #then uses awk to do the equivalent of sort -n | uniq -c |sort -rn
- #at the end of the line | then sorts alphabetically
- # Written by TVK 2015/07/27 - v 1.0
- # - Modified find, refined grep, added service var.
- # Updated by TVK 2015/10/28 - v 1.2
- # - Changed html layout, added IP0/49 finds.
- # Updated by TVK 2016/06/01 - v 1.3
- # - Modified HTML+CSS for GMail & Outlook form compatibility, Added HTML as attachment
- # Updated by TVK 2019/05/22 - v 1.4
- # - Added LDAP AUTH via 389 statement
- # - Shortened search quieries: https://stackoverflow.com/questions/56248792/
- # SOURCES
- # http://stackoverflow.com/questions/3317174/sending-html-mail-using-a-shell-script
- # http://www.unix.com/shell-programming-and-scripting/222753-sendmail-header-footer-logo-html-body.html
- # http://linuxcommand.org/wss0030.php
- # http://unix.stackexchange.com/questions/102092/mail-send-email-with-attachment-from-commandline
- # http://stackoverflow.com/questions/17359/how-do-i-send-a-file-as-an-email-attachment-using-linux-command-line
- #Source bashrc
- if [ -f /etc/bashrc ]; then
- . /etc/bashrc
- fi
- ##########################
- # SET VARIABLES #
- ##########################
- DATE="$(date +%Y-%m-%d)"
- TIME="$(date +%r)"
- LOGS="/log_dump/ldap/c*"
- Auth0="/log_dump/ldapreport/getbinds.txt"
- Auth49="/log_dump/ldapreport/getbindfails.txt"
- IPAuth0="/log_dump/ldapreport/ipauth0.txt"
- IPAuth49="/log_dump/ldapreport/ipauth49.txt"
- Auth389="/log_dump/ldapreport/ldap389.txt"
- Alumni="/log_dump/ldapreport/StudentAlumUSDLdapUsage.csv"
- NoAlumni="/log_dump/ldapreport/StudentAlumnotFound.txt"
- ServAcct="helpdes[a-z]*|svc-*|mptest[0-9]-*|sites|marketing|housing|testaccount|magent"
- EMAILBODY="/log_dump/ldapreport/emailbody.html"
- FROM="fromuser@site.com"
- TO="touser@site.com"
- SUBJECT="Monthly LDAP Authentication Summary"
- SENT="$(date)"
- MAILPART=`uuidgen`
- MAILPART_BODY=`uuidgen`
- export PATH=$PATH:/log_dump/ldapscripts:/opt/apps/home/sunone/Installer/jdk1.6.0_31/jre/bin
- export CLASSPATH=/log_dump/ldapscripts/
- export JAVA_BIN_DIR=/opt/apps/home/sunone/Installer/jdk1.6.0_31/jre/bin/
- ##########################
- # CLEANUP OLD #
- ##########################
- # Collect runtime of script start
- START="$(date +"%s")"
- sleep 1;
- # Move old emailbody and create new
- [[ -f $EMAILBODY ]] && mv "$EMAILBODY" "$EMAILBODY.bak"
- [[ ! -e "$EMAILBODY" ]] && touch "$EMAILBODY"
- # Move old email attachment and create new
- [[ -f catout.out ]] && mv "catout.out" "catout.out.bak"
- [[ ! -e "catout.out" ]] && touch "catout.out"
- # Move or Delete old getbinds and StudentAlums
- [[ -f $Auth0 ]] && mv "$Auth0" "$Auth0.bak"
- [[ ! -e "$Auth0" ]] && touch "$Auth0"
- [[ -f $Auth49 ]] && mv "$Auth49" "$Auth49.bak"
- [[ ! -e "$Auth49" ]] && touch "$Auth49"
- # Move old auth and create new
- [[ -f $IPAuth0 ]] && mv "$IPAuth0" "$IPAuth0.bak"
- [[ ! -e "$IPAuth0" ]] && touch "$IPAuth0"
- [[ -f $IPAuth49 ]] && mv "$IPAuth49" "$IPAuth49.bak"
- [[ ! -e "$IPAuth49" ]] && touch "$IPAuth49"
- [[ -f $Auth389 ]] && mv "$Auth389" "$Auth389.bak"
- [[ ! -e "$Auth389" ]] && touch "$Auth389"
- # Move old StudentAlumUSDLdapUsage and create new
- [[ -f $Alumni ]] && mv "$Alumni" "$Alumni.bak"
- [[ ! -e "$Alumni" ]] && touch "$Alumni"
- [[ -f $NoAlumni ]] && mv "$NoAlumni" "$NoAlumni.bak"
- [[ ! -e "$NoAlumni" ]] && touch "$NoAlumni"
- # Delete LDAP logs older than 93 days
- find /log_dump/ldap -mtime +93 -name "c*" -exec rm -f {} \; &&
- ##########################
- # GET LOGINS STATISTICS #
- ##########################
- #Get successful BIND 0 logins
- #
- #Find all logs older than 30 days |
- #Grab the line before word "RESULT err=0 tag-97" |
- #Grab word "BIND" | sed get the word starting after uid= and before "," |
- #Sed remove all blank lines | sed add a "," comma after each |
- #Awk sort all uniquely | sort by the 2nd column numbers
- #
- # tag=97 A result from a client bind operation.
- # err=0 SUCCESS LOGIN
- # err=49 FAILURE LOGIN
- [[ -f /tmp/logextract ]] && rm -f "/tmp/logextract"
- AuthTemp=$(mktemp -t logextract) || {
- echo "Error creating temp file" >&2
- exit 1
- }
- find $LOGS -mtime -30 -type f -exec grep -B 2 -Ew "RESULT err=(0|49) tag=97" {} + >"$AuthTemp"
- # GET SUCCESS BIND LOGINS
- grep -B 2 -w "RESULT err=0 tag=97" "$AuthTemp" | grep -w "BIND" | sed '/uid=/!d;s//&\n/;s/.*\n//;:a;/,/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth0;
- # GET FAILED BIND LOGINS
- grep -B 2 -w "RESULT err=49 tag=97" "$AuthTemp" | grep -w "BIND" | sed '/uid=/!d;s//&\n/;s/.*\n//;:a;/,/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth49;
- # GET SUCCESS BIND LOGIN IPs
- grep -B 2 -w "RESULT err=0 tag=97" "$AuthTemp" | grep -E "BIND|LDAP connection from" | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $IPAuth0;
- # Get FAILED BIND LOGIN IPs
- grep -B 2 -w "RESULT err=49 tag=97" "$AuthTemp" | grep -E "BIND|LDAP connection from" | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $IPAuth49;
- # Get INSECURE BIND LOGIN LDAP TCP/389
- grep -B 2 -w "LDAP connection from" "$AuthTemp" | grep -E 'LDAP connection from*' | sed '/from /!d;s//&\n/;s/.*\n//;:a;/:/bb;$!{n;ba};:b;s//\n&/;P;D' | sed 's/ //g' | sed s/$/,/g |awk '{a[$1]++}END{for(i in a)print i a[i]}' |sort -t , -k 2 -g > $Auth389;
- ##########################
- # GET STUDENT STATISTICS #
- ##########################
- $JAVA_BIN_DIR\java LDAPStuAlumBind_linux
- sleep 500;
- ##########################
- # GENERATE FUNCTIONS #
- ##########################
- function SUCC1
- {
- # Total number of all successful real user logins
- cat $Auth0 | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function SUCC2
- {
- # Total number of all successful service account logins
- cat $Auth0 | grep -Ew $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function FAIL1
- {
- # Total number of all failed real user logins
- FAIL1A="$(cat $Auth49 | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' )";
- if [ -z "$FAIL1A" ]
- then
- echo "0"
- else
- FAIL1A1="$(echo $FAIL1A | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
- echo $FAIL1A1
- fi
- }
- function FAIL2
- {
- # Total number of all failed service account logins
- FAIL2A="$(cat $Auth49 | grep -Ew $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' )";
- if [ -z "$FAIL2A" ]
- then
- echo "0"
- else
- FAIL2A0="$(echo $FAIL2A | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta')"
- echo "$FAIL2A0"
- fi
- }
- function TOTL1
- {
- # Total count of all real user account logins
- cat $Auth0 | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function TOTL2
- {
- # Total count of all service account logins
- cat $Auth0 | grep -Ew $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- ##########################
- # GENERATE STUDENT STATS #
- ##########################
- function STUDS1
- {
- # Total number of all successful student logins
- cat $Alumni | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function STUDS2
- {
- # Total Unique student account logins
- cat $Alumni | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function STAFF1
- {
- # Total number of all Faculty & Staff logins
- cat $NoAlumni | grep -Ev $ServAcct | awk -F ',' '{sum+=$2} END {print sum}' | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function STAFF2
- {
- # Total Unique Faculty & Staff logins
- cat $NoAlumni | grep -Ev $ServAcct | cut -f 2 | wc -l | sed ':a;s/\B[0-9]\{3\}\>/,&/;ta'
- }
- function TOP10S
- {
- # Top 10 successful user logins
- echo "<pre>"
- cat $Auth0 | grep -Ev $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
- echo "</pre>"
- }
- function TOP10F
- {
- # Top 10 failed user logins
- echo "<pre>"
- cat $Auth49 | grep -Ev $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- function TOP10SS
- {
- # Top 10 successful service logins
- echo "<pre>"
- cat $Auth0 | grep -Ew $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- function TOP10FS
- {
- # Top 10 failed service logins
- echo "<pre>"
- cat $Auth49 | grep -Ew $ServAcct | tail -n 10 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- ##########################
- # GENERATE DEST IP STATS #
- ##########################
- function TOP10IPS
- {
- # Top 10 IPs where login is successful from
- echo "<pre>"
- tail -n 10 $IPAuth0 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- function TOP10IPF
- {
- # Top 10 IPs where login is failed from
- echo "<pre>"
- tail -n 10 $IPAuth49 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- function TOP30Auth389
- {
- # Top 30 FROM LDAP 389
- echo "<pre>"
- tail -n 30 $Auth389 | sed 's/\\n/\n/g' | tac
- echo " "
- echo "</pre>"
- }
- ##########################
- # ENDING SCRIPT TIME #
- ##########################
- # Get end runtime of script
- END="$(date +"%s")"
- # Get total runtime in seconds
- DIFF="$(($END-$START))"
- # Total runtime in minutes
- RUNTIME="$(echo "Total Script runtime: $(($DIFF / 60)) minutes and $(($DIFF % 60)) seconds.")"
- #######################
- # GENERATE EMAIL BODY #
- #######################
- spacer=----------------------------
- HEADERIMG=$LDPATH/Header.jpg
- HEADER="Monthly LDAP Summary Ending on $DATE"
- TITLE="Monthly LDAP Summary"
- (cat <<- _EOF_
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>$TITLE</title>
- <meta http-equiv="Content-Type" content="text/html; charset=unicode">
- </head>
- <body><p>
- </head>
- <style type='text/css'>
- table {
- width: 100%;
- margin: 0px;
- padding: 0px;
- }
- tr:nth-child(even) {
- background-color: #e5e5e5;
- }
- td {
- vertical-align: top;
- font-family: Tahoma, Sans-Serif;
- font-size: 11pt;
- padding: 0px;
- }
- th {
- vertical-align: top;
- color: #000000;
- text-align: left;
- font-family: Tahoma, Sans-Serif;
- font-size: 11pt;
- }
- .pluginContent td { padding: 5px; }
- .warning { background: #FFFBAA !important }
- .critical { background: #FFDDDD !important }
- </style>
- <body style="padding: 0 10px; font-family:Arial, Helvetica, Sans-Serif; ">
- <a name="top" />
- <table width='100%' style='background-color: white; margin: 0; padding: 0;'>
- <tr>
- <td style='background-color: white; font-size: 2pt;'>
- <img src=https://www.sandiego.edu/brand/images/logos/master-primary/usd-logo-primary-2c.png alt=' USD LDAP Auth Summary' />
- </td>
- </tr>
- </table>
- <div style='height: 10px; font-size: 10px;'> </div>
- <table width='100%'><tr><td style='vertical-align: middle; text-indent: 10px; font-family: Tahoma, Sans-Serif; font-weight: bold; font-size: 14pt; color: #000000;'>$HEADER</td></tr></table>
- <div>
- <hr size="8" color="#002868">
- <table width='100%' style='padding: 0px; border-collapse: collapse; font-family:Arial,Helvetica,Sans-Serif; border-collapse; word-break:normal; vertical-align:middle;'>
- <tr>
- <th colspan="4" style='font-weight:bold; font-size:28px; background-color:#008dd6; color:#FFFFFF; text-align:center; padding:1px 1px; border-style:solid; border:1px solid #008DD6; border-width:1px;'>ACCOUNT LOGIN INFORMATION</th>
- </tr>
- <tr style='border-bottom: 1px solid #E0E0E0;'>
- <td style='font-weight:bold; font-size:20px; text-align:right;'></td>
- <td style='font-weight:bold; font-size:20px; text-align:right;'>Successful Logins</td>
- <td style='font-weight:bold; font-size:20px; text-align:right;'>Failed Logins</td>
- <td style='font-weight:bold; font-size:20px; text-align:right;'>Unique Accounts</td>
- </tr>
- <tr style='border-bottom: 1px solid #E0E0E0;'>
- <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Student Logins</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STUDS1)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>N/A</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STUDS2)</td>
- </tr>
- <tr style='border-bottom: 1px solid #E0E0E0;'>
- <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Fac-Staff Logins</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STAFF1)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>N/A</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(STAFF2)</td>
- </tr>
- <tr style='border-bottom: 1px solid #E0E0E0;'>
- <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Total User Logins</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(SUCC1)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(FAIL1)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(TOTL1)</td>
- </tr>
- <tr>
- <td style='font-weight:bold; font-size:20px; text-align:left; padding:0px 0px 0px 10px; vertical-align:middle;'>Service Accounts</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(SUCC2)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(FAIL2)</td>
- <td style='font-weight:normal; font-size:14px; text-align:right; padding:0px 10px 0px 0px; vertical-align:middle;'>$(TOTL2)</td>
- </tr>
- </table>
- <table width='100%'>
- <tr>
- <td style='vertical-align: middle; text-indent: 10px; font-family: Tahoma, Sans-Serif; font-weight: bold; font-size: 12pt; color: #000000;'> </td>
- </tr>
- </table>
- <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
- <tr>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 LOGINS - USER</th>
- <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED - USER</th>
- </tr>
- <tr>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10S)</td>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10F)</td>
- </tr>
- </table>
- <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
- <tr>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 LOGINS - ServAcct</th>
- <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED - ServAcct </th>
- </tr>
- <tr>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10SS)</td>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border: 1px solid transparent;'>$(TOP10FS)</td>
- </tr>
- </table>
- <table width='100%' style='font-family:Arial,Helvetica,Sans-Serif; border-collapse:collapse; border-spacing:0; border:1px solid transparent; word-break:normal; vertical-align:middle;'>
- <tr>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#BAFFBA; padding:1px 1px; border:1px solid transparent;'>TOP 10 SOURCE IP</th>
- <th width='2%' rowspan="2" style='font-size:14px; vertical-align:inherit; border:1px solid transparent; background-color:transparent; color:transparent;'></th>
- <th width='49%' colspan="5" style='font-weight:bold; font-size:20px; text-align:center; background-color:#008DD6; color:#FFBABA; padding:1px 1px; border:1px solid transparent;'>TOP 10 FAILED SOURCE IP</th>
- </tr>
- <tr>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP10IPS)</td>
- <td colspan="5" valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP10IPF)</td>
- </tr>
- </table>
- <table width='100%' style='padding: 0px; table-layout:fixed; border-collapse: collapse;'>
- <tr>
- <th colspan="4" style='font-weight:bold; font-size:14pt; background-color:#008DD6; color:#FFBABA; text-align:center; padding:1px 1px; border-style:solid; border-width:1px; border:1px solid;'>TOP 30 SERVERS USING INSECURE LDAP 389</th>
- </tr>
- <tr>
- <td style='word-wrap:break-word; margin:0px; color:#000000; valign="top" style='font-size:14px; color:#000000; background-color:transparent; border:1px solid transparent;'>$(TOP30Auth389)</td>
- </tr>
- </table>
- <table width='100%' style='padding: 0px; border-collapse: collapse;'>
- <tr>
- <th colspan="4" style='font-weight:bold; font-size:14pt; background-color: #008DD6; color:#E1E1E1; text-align:center; padding:1px 1px; border-style:solid; border-width:1px; border:1px solid #008DD6;'>SCRIPT RUNTIME</td>
- </tr>
- <tr>
- <td style='margin:0px; color:#000000; font-style:italic; font-size:12pt; text-indent:10px; vertical-align:middle;'>$RUNTIME</td>
- </tr>
- <td style='margin:0px; color:#000000; font-style:italic; font-size:12pt; text-indent:49px; vertical-align:middle;'>Completed at: $TIME</td>
- </tr>
- </table>
- </div>
- <!-- CustomHTMLClose -->
- <div style='height: 10px; font-size: 10px;'> </div>
- <table width='100%'>
- <tr>
- <td style='font-size:9pt; height: 25px; text-align: center; vertical-align: middle; color: #000000;'>Written by TVK, Systems Architect, University of , number</td>
- </tr>
- </table>
- </body>
- </p>
- </html>
- _EOF_
- echo "";
- ) > $EMAILBODY
- ##########################
- # CREATE E-MAIL #
- ##########################
- (
- echo "From: $FROM"
- echo "Sent: $SENT"
- echo "To: $TO"
- echo "Subject: $SUBJECT"
- echo "MIME-Version: 1.0"
- echo "Content-Type: multipart/mixed; boundary=\"$MAILPART\""
- echo ""
- echo "--$MAILPART"
- echo "Content-Type: multipart/alternative; boundary=\"$MAILPART_BODY\""
- echo ""
- echo "--$MAILPART_BODY"
- echo "Content-Type: text/plain; charset=ISO-8859-1"
- echo "You need to enable HTML option for email"
- echo "--$MAILPART_BODY"
- echo "Content-Type: text/html; charset=UTF-8"
- echo "Content-transfer-encoding: us-ascii"
- echo "Content-Disposition: inline"
- cat $EMAILBODY
- echo "--$MAILPART"
- echo 'Content-Type: text/csv; name="'$(basename $Alumni)'"'
- echo "Content-Transfer-Encoding: uuencode"
- echo 'Content-Disposition: attachment; filename="'$(basename $Alumni)'"'
- echo ""
- (uuencode $Alumni $(basename $Alumni))
- echo "--$MAILPART--"
- ) > catout.out
- ##########################
- # SEND E-MAIL #
- ##########################
- cat catout.out | /usr/sbin/sendmail $TO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement