Koozali.org: home of the SME Server
Legacy Forums => General Discussion (Legacy) => Topic started by: BobWilliams on November 09, 2004, 05:28:02 PM
-
I need to create a script to have Crontab execute a job that emails the output of say "df -h" to the admin account field 'forwarding address for administrative messages' but I don't know the script commands. Can anyone help me?
Bob...
-
you could always write the output of df to a file and then use mail to send it to an email address.
shove it into cron and you should get regula emails
-
Thanks for the reply kbensch. I did just that.
'date' > /df-test
mail -s "subject" mail-address < /df-test
and used the new SME Server Manager - Crontab Manager panel to launch the script. Works great.
Bob...
-
I have a script for emailing ping logs to my email address for work. Its a bit crude, but works.
FROMMAIL="XXXXXXXXX@XXXXXX.com"
TOMAIL="XXXXXXXXXX@XXXXXX.com"
MAILFILE=/tmp/basename ${0}.$$
PINGLOG="/export/home/szr52z/log/vpn_log.txt"
SentPage() {
DATE=date "+%H:%m %Y-%m-%d"
echo "From: ${FROMMAIL}" > ${MAILFILE}
echo "To: ${TOMAIL}" >> ${MAILFILE}
echo "Subject: [VPN Ping Report]." >> ${MAILFILE}
echo "Content-Type: text/plain; charset=us-ascii" >> ${MAILFILE}
echo "Content-Transfer-Encoding: 7bit\n\n" >> ${MAILFILE}
echo " " >> ${MAILFILE}
echo "Time stamp: ${DATE}." >> ${MAILFILE}
echo " " >> ${MAILFILE}
echo "The failed ping attempts are as follows:" >> ${MAILFILE}
echo " " >> ${MAILFILE}
echo "-----------" >> ${MAILFILE}
/usr/bin/cat ${PINGLOG} >> ${MAILFILE}
/usr/lib/sendmail -oi -t -oem < ${MAILFILE}
}
main() {
if [ "${PINGLOG}" != "" ] ; then
SentPage
fi
}
main
Tho SME doesn't have send mail, it might help give an idea atleast.
-
Thanks for the input monkey. That script will be a great help to me learning scripting on SME. I think this product is great and the support the members provide is outstanding.
Thanks
Bob...