Hello all,
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.
Here is my code:
#!/bin/bash
clear
COUNT=0
SYSTEMS=`cat systems.txt`
while [ "$CHOICE" != "q" ]
do
for SYSTEM in $SYSTEMS
do
COUNT=`expr $COUNT + 1`
echo "$COUNT. $SYSTEM"
done
echo ""
echo "Please choose."
echo ""
read CHOICE
COUNT=0
clear
done
What I have so far example:
1. host1
2. host2
3. host3
Please choose.
3
What I'd like example:
1. host1
2. host2
3. host3
Please choose.
3
You picked host3!
The hostnames are not always host* of course, so I can't use that as a convention for the script to know which server I mean.
Any help would be awesome. Thanks guys.