AIX NFS Check

Good day
On a AIX system I would like to see if a NFS mount is not set to auto mount, the desired output should be Mount name and Yes or NO.

My test environment has 3 NFS mounts of which only 1 is set to auto mount.

lsfs -v nfs | read -r Name Nodename Mount VFS Size Options Auto Accounting

if [ $Auto = no ]
then
    echo $Mount NO
else
    echo $Mount YES
fi

#output

Mount YES

My output does not show the mount name and seems to only read the first line

Thank you

The read from a pipe is executed in a subshell, and thus the varables read are lost when the subshell finishes. Neither Mount nor Auto are set within the if construct. I'd be surprised if your output really showed "Mount"

You need a while loop!

lsfs -v nfs |
while read Name Nodename Mount VFS Size Options Auto Accounting
do
  if [ "$Auto" = no ]
  then
    echo "$Mount NO"
  else
    echo "$Mount YES"
  fi
done

To exclude the header line

lsfs -v nfs | {
read header
while read Name Nodename Mount VFS Size Options Auto Accounting
do
  if [ "$Auto" = no ]
  then
    echo "$Mount NO"
  else
    echo "$Mount YES"
  fi
done
}
1 Like

Thank you that works awesome