Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically send mail

Status
Not open for further replies.

neetsw

IS-IT--Management
Apr 5, 2004
21
ZA
Hi, I need a script that automatically send mail every day with the tail of a certain file. Any help on how I must do this will be appreciated. (Is there any way to use sendmail so that it doesn't use the mail server as a relay server, because relaying is not enabled on our mail server (lotus notes serevr) Thanks.
 
smtp

Do you have a Domino smtp server ? If so, just mail the log to your company E-mail address...such as this:

#!/bin/ksh
#
#
#################################################################
# #
# This script will be used to determine various system activies #
# and status in the morning or any time. #
# #
# #
# By:Corey Date: 05/18/01 #
#################################################################
>beer
echo "\n Current date/time: `date +%T` `date +%D`\n" >> beer
echo " " >> beer
chips=`lsdev -Cc disk|grep Available|grep TimeFinder|wc -l|awk '{print $1}'`
echo "CHECKING TO SEE TF DISK STATUS:" >> beer
echo "$chips TimeFinder disks available" >> beer
if [ "$chips" -lt 11 ]
then
echo "All TimeFinder disks are not there!" >> beer
else
echo "All TimeFinder disks are there!" >> beer
fi
####################################################################
echo " " >> beer
echo "CHECKING TO SEE IF PR1 VOLUME GROUPS ARE STILL ON THE H80:" >> beer
lsvg|grep SAPPR1VG > /dev/null
if [ $? -eq 0 ]
then
echo "SAPPR1VG is still on the H80" >> beer
else
echo "SAPPR1VG is not on the H80" >> beer
fi
####################################################################
echo " " >> beer
echo "CHECKING TO SEE IF PR1ADM PROCESSES ARE RUNNING:" >> beer
tv=`ps -ef|grep pr1adm|grep -v grep|wc -l`
tv1=`ps -ef|grep db2pr1|grep -v grep|wc -l`
if [ "$tv" -gt 0 -o "tv1" -gt 0 ]
then
echo "There are $tv pr1adm processes running" >> beer
echo "They are:" >> beer
ps -ef|grep pr1adm >> beer
echo "There are $tv1 db2pr1 processes running" >> beer
echo "They are:" >> beer
ps -ef|grep db2pr1 >> beer
else
echo "There are NO pr1adm processes running" >> beer
fi
####################################################################
echo " " >> beer
echo "CHECKING THE ERRPT:" >> beer
moe=`errpt|wc -l`
if [ "$moe" -gt 0 ]
then
errpt >> beer
else
echo "There is nothing in the ERRPT" >> beer
fi
####################################################################
echo " " >> beer
echo "SEE WHO IS ON AND HOW LONG:" >> beer
ps -ef|grep xterm|grep -v grep|awk '{print $1" ",$5,$8}' >> beer
echo " " >> beer
who >> beer
####################################################################
echo " " >> beer
echo "SEE WHERE THE BK's AND THE DV's ARE:" >> beer
lsvg1=`lsvg|grep SAPPR0BK`
if [ "$lsvg1" = "SAPPR0BK" ]
then
echo "The BK's are on the H80" >> beer
else
echo "The BK's are NOT on the H80" >> beer
fi
lsvg2=`lsvg|grep SAPDV1BK`
if [ "$lsvg2" = "SAPDV1BK" ]
then
echo "The DV's are on the H80" >> beer
else
echo "The DV's are NOT on the H80" >> beer
fi
####################################################################
mail -s "Morning Log for `hostname`" root < beer
#mail -s "Morning Log for `hostname`" cp < beer
####################################################################

Now, create an alias in /etc/aliases (or /etc/mail/aliases under AIX 5.x) such as this:


root:bverzal,jamundsen
bverzal:bverzal@komatsuna.com
jamundsen:jamundsen@komatsuna.com


Run 'newaliases' and you should be good to go.

BV
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top