#!/bin/ksh
# 17nov2004 john meister
# purpose: script to execute command on all servers - encapulate in quotes
# must be run from sysadmin-server
USAGE="usage: sh ./runnow.sh , runs command on all servers - NOTE: use quotes"
##################################
# HEADER and FILE INFO
##################################
CMD="`echo "$1" | tr ' ' '_' | tr '/' '-' | tr '|' '-' `" ; export CMD
DATE=`date | cut -c 5-11` ; export DATE
FDATE=`/usr/bin/date +%d%b%y-%H%M` ; export FDATE
FNAME="$CMD.$FDATE" ; export FNAME
LOG="/var/apache/htdocs/Info/$FNAME.txt" ; export LOG
echo " -- $CMD -- on $DATE -- "| tee $LOG ###### NOTE writes over file when reexecuted ######
echo " ----------------------------------------------- "| tee -a $LOG
##################################
# Solaris 9 systems use ssh
##################################
HOSTS="host1 host2 host3 host4
host5 host6 host7 host8" ; export HOSTS
#
for x in $HOSTS
do
echo "\n### $x (`ssh $x uname -r` on `ssh $x uname -i | awk -F, '{print $2}'`) ###" | tee -a $LOG
ssh $x $1 | tee -a $LOG
done
##################################
# Solaris 8 systems use rsh
##################################
HOSTS8="host9 host10 host11 host12
host13 host14 host15" ; export HOSTS8
#
for x in $HOSTS8
do
echo "\n### $x (`rsh $x uname -r` on `rsh $x uname -i | awk -F, '{print $2}'`) ###" | tee -a $LOG
rsh $x $1 | tee -a $LOG
done
#
##################################
echo " ------------- " | tee -a $LOG
echo "webpage: http://sysadmin.server.com/Info/$FNAME.txt" | tee -a $LOG
echo " ------------- " | tee -a $LOG
mailx -s " $1 (`date +%d%b%y`)" jm < $LOG
##################################
|