This probably isn't the correct forum for this but these Forums have a lot of knowledge so I thought I would give this a shot.

I'm working on a bash script for a linux thin client where the script will check if the Thin Client is connected to the Virtual Machine. If it's not the script will reconnect to the VM. I know I can load up the script (like I've done so far) with the various IP addresses. What I'd like to do instead is list my variables of Hostname and their IP Address in a config file and then have my script check the hostname of the current computer, and find the hostname in the config file and use the IP Address. So far I've got it working where it reads the hostname and finds the IP to use based on the case statement without using a config file. This is what I have so far.

# Check if rdesktop is running
read var < ipfile
if pgrep rdesktop > /dev/null
        echo "$(date "+%m%d%Y %T") : rdesktop is already running." >> $LOGFILE$
        exit 0
        echo "$(date "+%m%d%Y %T") : rdesktop has Stopped. Attempting to resta$
        case $THISHOST in
          (rpiA) rdesktop -z -u user -p password;;
          (rpiB) rdesktop -z -u user -p password;;
          (rpiC) rdesktop -z -u user -p password;;
        exit 0

Right now my code is not using the line: read var < ipfile

So I would like list all my server IP's in the ipfile like this:


And then modify my code to reference the variables in ipfile in my script. I'm assuming I wouldn't use a case statement any longer, probably a for loop.

Any assistance you can give me on how best to accomplish this task would be greatly appreciated.

Thank you.