I have the following script to check if a NFS mount is currently mounted on the server :
#!/bin/bash
$targetserver=192.168.3.1
commandline="mount | grep '$targetserver' | wc -l"
checkmount=`$commandline`
if [ $checkmount == "1" ]; then
echo "Mounted !"
else
echo "Not mounted"
fi
But it seems that my checkmount is not returning anything.
What am I missing here ?
This should work better.
You could shorten it down though, using
$?, redirection and control operators.Depending on system
grep /etc/mtabdirectly might be a good idea too. Not having to executemountwould be cleaner imho.Cheers!