I am hoping someone can help me with this one.
I am writing a ksh script on Solaris. I want to read in host names and some other info from a file, do an "rsh host 'shutdown'" (or any uname for now until I get it working), and then be given some options. The problem is I am using while read LINE do with a nested read like this:
cat hosts.lst | while read LINE
do
set ${LINE}
rsh ${1} 'uname -a'
DONE=false
while [[ ${DONE} = false ]]
do
echo "[C]heck, [K]ill, [G]o?"
read ANSWER
ANSWER=`echo ${ANSWER} | tr -s '[:lower:]' '[:upper:]'`
echo "ANSWER is ${ANSWER}"
case ${ANSWER} in
C ) check_running_processes;;
K ) kill_running_processes;;
G ) DONE=true;; #go to next priority
esac
done
This isn't the entire script just the section I am having problems with. The problem I cannot get around is when I try to "read ANSWER", $ANSWER is getting the value of $LINE for that iteration. I understand why this is happening but cannot figure out how to get around it.
I have tried putting the read in (), in a separate subroutine, unsetting $LINE, setting $LINE to something else.
Any other ideas?
Thanks,
Tony