Linux nfs装入shell脚本中需要一元运算符
我只需要安全程序。nfs装载、数据rsync和shell已结束Linux nfs装入shell脚本中需要一元运算符,linux,bash,shell,mount,nfs,Linux,Bash,Shell,Mount,Nfs,我只需要安全程序。nfs装载、数据rsync和shell已结束 rmv=`cat /proc/mounts | grep /mnt/nfs | cut -d: -f2 | awk '{print $2}'` if [ $rmv != $@ ]; then echo "not mounted" else if umount /mnt/nfs > /dev/null 2>&1 || /bin/false; then umount successed else dev
rmv=`cat /proc/mounts | grep /mnt/nfs | cut -d: -f2 | awk '{print $2}'`
if [ $rmv != $@ ]; then
echo "not mounted"
else if umount /mnt/nfs > /dev/null 2>&1 || /bin/false; then
umount successed
else
device is busy"
fi
fi
正在工作,但是
'[' /mnt/nfs '!=' ']'
[: /mnt/nfs: unary operator expected
我用了$@我想我的表达是错误的。需要其他方法实际上,您的初始脚本中有相当多的缺陷,以及一些不必要的代码/命令使用。。。。这是你想要的吗?注意-它未经测试,但我认为它在语法上是正确的
rmv=$(awk -F"[: ]+" '/\/mnt\/nfs/{print $2}' /proc/mounts)
if [ $rmv == "" ]; then
echo "not mounted"
else
if umount /mnt/nfs > /dev/null 2>&1 ; then
echo "umount succeeded"
else
echo "device is busy"
fi
fi
请解释您所说的安全过程等是什么意思。不清楚您试图做什么。您没有向脚本传递任何参数,因此$@为空,因此出现错误。使用$@没有帮助,因为这是神奇的扩展参数,但保持引用表达式,所以它仍然是空的。你想做什么?只是想自由地同步进程。在操作进程时,它可以通过crontab进行umount@donatelloif[$rmv!=$@];那就意味着检查底座@马克里德