
#!bin/sh
# File	: ontap_cmds.sh
# By	: Maarten.deBoer@atos.net, 2600702
# Subject	: Script to launch a list of ONTAP-commandos
PGM=`basename $0|cut -d\. -f1`
VER="0.1"
LOG="${HOME}/log/${PGM}.log"
SESSION="/tmp/${PGM}-`date +%Y%m%d-%H%M%S`.log"
SSH="/usr/bin/ssh -n"
MAILTO="maarten.deboer@atos.net"

CMDS="${HOME}/etc/${PGM}.cmds"
CLUSTER="nlnaf102"

echo "`date` ${PGM} v${VER} started. (SESSION=${SESSION})"|tee -a ${LOG} ${SESSION}
echo " "|tee -a ${SESSION}
echo "  CLUSTER=${CLUSTER}:"|tee -a ${LOG} ${SESSION}
echo " "|tee -a ${SESSION}
sleep 1

cat ${CMDS} | grep -v ^#|while read LINE
do
  echo "${LINE} : "|tee -a ${SESSION}
  ${SSH} ${CLUSTER} "${LINE}" | tee -a ${SESSION}
  echo " "|tee -a ${SESSION}
  sleep 1
done  # LINE

if [ "${MAILTO}" != "" ]; then
  date | mailx -a ${SESSION} -s "${PGM} v${VER}" ${MAILTO}
  echo "  Mailed to ${MAILTO}"|tee -a ${LOG}
fi  # MAIL

echo "`date` ${PGM} v${VER} finished."|tee -a ${LOG}
exit 0

