1. #!/bin/sh
    2. Alpha=`df -h |grep "//10.12.8.106/Version/EMS/EMS_Embedded/Alpha"`
    3. #如果Alpha为空,就执行挂载磁盘命令
    4. #如果Aplha存在就不执行后面的命令
    5. #只有在 && 左边的命令返回真(命令返回值 $? == 0),&& 右边的命令才会被执行。
    6. [ -z $Alpha ] && mount -t cifs //10.12.8.106/Version/EMS/EMS_Embedded/Alpha /opt/goldwind/ShareFolder/ -o username=zhanghongyu41031@goldwind.com,password=Haishui163,gid=0,uid=0,dir_mode=0777,file_mode=0777
    7. #方便看但不够简洁的写法
    8. Alpha=`df -h |grep "//10.12.8.106/Version/EMS/EMS_Embedded/Alpha"`
    9. if [ -z $Alpha ]
    10. then
    11. mount -t cifs //10.12.8.106/Version/EMS/EMS_Embedded/Alpha /opt/goldwind/ShareFolder/ -o username=zhanghongyu41031@goldwind.com,password=Haishui163,gid=0,uid=0,dir_mode=0777,file_mode=0777
    12. else
    13. break
    14. fi