对于以下脚本,我在意外标记“else”附近出现语法错误

对于以下脚本,我在意外标记“else”附近出现语法错误
    if ! [ $result1 -eq $SUCCESS ]; then

        # failed to get the status from 1st ssd try with the 2nd ssd, to identify the primary and secondary
        mount_diagnostic_partition_read_ssdStatus_file $by_id_2_new
        result2=`echo $?`

        # check the result, is the primary and secondary ssd identification done
        if ! [ $result2 -eq $SUCCESS ]; then

            # attempt 2 also failed to identify the primary and secondary
            # check is both attempt failure are due to mount
            if  [ $result1 -eq  $MOUNT_FAIL -a $result2 -eq $MOUNT_FAIL ]; then

                # ssd are there but unable to mount, so go out of ssd management and proceed with CFAST
                echo "Mount failed for both SSD's"
                ssd_logger "Mount failed for both SSD's"
                echo "So exiting detect_SSD'S fn"
                ssd_logger "So exiting detect_SSD'S fn"
                echo "Booting with CFAST"
                ssd_logger "Booting with CFAST"
                mkdir -p $CFAST_PATH
                echo "CFAST" > $CFAST_PATH/failoverstatus
                retval=$MOUNT_FAIL
                #setLogDirs "cfast"
                #exit 0
            fi

            # if primary and secondary ssd identification due to no ssd file then
            # consider the ssd which are detected in the order as primary and proceed,
            # create the ssd file and sync it at the end
            #ssd_logger "Coming out of detectSSD's "
            #return $retval
        else
            echo "Mounting Primary diagnostics partiton failed for $by_id_1_new and successfull for $by_id_2_new"
            ssd_logger "Mounting Primary diagnostics partiton failed for $by_id_1_new and successfull for $by_id_2_new"
            retval=$SSD_2_SUCCESS
        fi
    else    **#error line**
        echo "Mounting Primary diagnostics partiton was successfull for $by_id_1_new"
        ssd_logger "Mounting Primary diagnostics partiton was successfull for $by_id_1_new"

答案1

有一个fi缺失:你有三个if,但你的第一个没有在任何地方关闭......

相关内容