![对于以下脚本,我在意外标记“else”附近出现语法错误](https://linux22.com/image/58534/%E5%AF%B9%E4%BA%8E%E4%BB%A5%E4%B8%8B%E8%84%9A%E6%9C%AC%EF%BC%8C%E6%88%91%E5%9C%A8%E6%84%8F%E5%A4%96%E6%A0%87%E8%AE%B0%E2%80%9Celse%E2%80%9D%E9%99%84%E8%BF%91%E5%87%BA%E7%8E%B0%E8%AF%AD%E6%B3%95%E9%94%99%E8%AF%AF.png)
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
,但你的第一个没有在任何地方关闭......