I have the below script and I'm a little stuck on the best way to continue.
Essentially I'm creating a text file (systems.txt) with a list of servers in it by hostname. Then I would like to echo a menu with each hostname and a number to use to pick it from the list. It's somehow associating the number with the hostname that is confusing me.
#!/bin/ksh
hosts='/tmp/hosts.txt'
PS3="Pick one of the above: "
select i in $(< ${hosts})
do
[ $i ] && print "you picked->[${i}]" || print -u2 'invalid selection'
done
Here is what I have now, which is working well. I'm using ssh as a test of the menu. Once I log into the server I choose, and then logout, it doesn't redraw the menu choices again for the next choice. Is there a way I can make it redraw the choices after that first loop completes?
#!/bin/ksh
clear
HOSTS='systems.txt'
PS3="Please choose a system: "
select i in $(< ${HOSTS})
do
if [ "$REPLY" = "q" ]
then
break
fi
[ $i ] && print "" || print -u2 'Invalid Choice'
clear
ssh -X ${i}
done