I'm trying to retrieve a value in a for loop but have failed with every effort. In this script, I have to declare the remote path for my SSHFS mount script. In the code below, I'm storing the path in an array of user[remote]. Further down in the script, this user is being held in $left. So air[remote] would be $left[remote]. I can't figure out how to do this, however. My latest effort, ${!left[remote]} didn't result in any error but just results in a null value.
How do I get the remote path value dynamically with $left[remote]?
#!/bin/bash
declare -A air
air[remote]="/home/air"
declare -A bhm
bhm[remote]="/home/bhm"
declare -A schwimserver3
schwimserver3[remote]="/var/www/clients/client1/web7/home/schwimserver3"
#echo ${air[remote]}
for u in $HOME/Remote/SSHFS/*
do
if [ -d $u ]; then
basename "$u" >/dev/null
acct="$(basename -- $u)"
IFS=- read -r left right <<< "$acct"
if mountpoint "${HOME}/Remote/SSHFS/${acct}" >/dev/null; then
printf '%b\n' "unmount ${right},fusermount -u /home/schwim/Remote/SSHFS/${right}"
else
printf '%b\n' "mount ${right},sshfs -o workaround=rename $left@$right:${!left[remote]} /home/schwim/Remote/SSHFS/${acct}"
fi
fi
done
thanks for your time!