The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > OS X (Apple)
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 04-21-2009
mlott mlott is offline
Registered User
  
 

Join Date: Apr 2009
Posts: 1
Hi

This is a starting point I guess, so I hope it is of some help. Not sure why you want to use Entourage specifically when you can use the "mail" program that comes pre-compiled in OS X, but hey, whatever you need.

Firstly you'll need to get the list somewhere on the filesystem. In this example script it is in a file called sus_list.txt under the /tmp/ directory.


Code:
!/bin/sh

#============================
# Define admin email address
NOTIFY="one@you.com, two@you.com"

# Get computer name
C_NAME=`/usr/sbin/scutil --get ComputerName`

# Define a function
mailOUT ()
{
        echo From: ${C_NAME} - Monday Morning ARD SUS Notification \
        > /tmp/sus_mailout.txt
        echo ----- >> /tmp/sus_mailout.txt
        echo Timestamp: `date` >> /tmp/sus_mailout.txt
        echo ----- >> /tmp/sus_mailout.txt
        echo "Please find below the list of clients that need patching" \
        >> /tmp/sus_mailout.txt
	echo ----- >> /tmp/sus_mailout.txt
	echo "" >> /tmp/sus_mailout.txt
	cat /tmp/sus_list.txt >> /tmp/sus_mailout.txt
        cat /tmp/sus_mailout.txt | mail -s "From: ${C_NAME} - Monday \
        Morning ARD SUS Notification" ${NOTIFY}
}

if [ -f /tmp/sus_list.txt ]
then
	mailOUT
else
	# log error to the syslog
	logger "SUS: File /tmp/sus_list.txt does not exist"
fi
exit 0
This script will have to be made executable or called like this

Code:
sh /path/to/script
I usually place scripts like this in /usr/local/scripts/ but that is a personal preference.

Normally I'd say to use Launchd to handle the scheduling of the script, but the StartCalendarInterval is not tuned enough for this at present, so it's back to good old cron. Personally, I wouldn't have this run by the root account as there is nothing in there that requires root privileges. To that end, in your crontab, add the following so that it will run at 0900 every Monday:

Code:
0 9 * * 1 /usr/local/scripts/mailout.sh
HTH a bit,

Mike