I am currently working on the logic associated with testing for stale NFS mounts in my environment.
However, I am at a lost as to why the loop in my first case condition only gives me the first value from the file being passed then drops back to the menu options. I am aware that the stale variable currently does not check against anything but it should not keep the looping construct from working.
Thank you for your assistance.
I.T. where a world of choas and confusion comes down to nothing but 1s and 0s.
However, I am at a lost as to why the loop in my first case condition only gives me the first value from the file being passed then drops back to the menu options. I am aware that the stale variable currently does not check against anything but it should not keep the looping construct from working.
Code:
#!/bin/sh
clear
PS3='Select option: '
options=("Stale NFS Clients" "Check Server Stale NFS Mounts" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Stale NFS Clients")
while read line
do
ssh root@$line lsof | egrep '/stale/fs|/export/backup' | awk '{print $2;}' | sort -fu | wc -l
if [ $stale > 0 ]
then
lsof | egrep '/stale/fs|/export/backup' | awk '{print $2;}' | sort -fu
else
echo "There are no stale NFS mount for $line"
fi
done < ExportClients
;;
"Check Server Stale NFS Mounts")
echo -n "Enter hostname to test for stale NFS mounts: "
read server
ssh root@$server lsof | egrep '/stale/fs|/export/backup' | awk '{print $2;}' | sort -fu | wc -l
if [ $stale > 0 ]
then
lsof | egrep '/stale/fs|/export/backup' | awk '{print $2;}' | sort -fu
else
echo "There are no stale NFS mount for $server"
fi
;;
"Quit")
break
;;
*) echo Invalid Option;;
esac
done
Thank you for your assistance.
I.T. where a world of choas and confusion comes down to nothing but 1s and 0s.