Shell脚本无法在脚本中执行所有if else语句

时间:2016-05-06 16:48:08

标签: shell

我有以下脚本在bash中执行

#!/bin/bash
###
### Author: Sam
###
Usage(){
    echo "Script Location: /fsnadmin/Warroom_sustenance/p4fa_automate"
    echo "Usage: P4FA_automate.sh  LBOX_PSWD"
}

if [ "$1" == "" ]; then
Usage
    exit 0
fi

LBOX_PSWD="$1"
LBOX_PSWD=`echo $LBOX_PSWD`

# source the properties:
. /fsnadmin/Warroom_sustenance/p4fa_automate/input.properties

echo "NumberOfPods = $NumberOfPods"
echo "MC_HOST = $MC_HOST"
echo "MC_ROOT_USER = $MC_ROOT_USER"
echo "MC_ROOT_PSWD = $MC_ROOT_PSWD"
echo "LBOX_USER = $LBOX_USER"
echo "LBOX_HOST = $LBOX_HOST"
echo "RELEASE = $RELEASE"
echo "E2EPATH = $E2EPATH"
echo "P4FALABEL = $P4FALABEL"
echo "P4FA_LOCATION = $P4FA_LOCATION"
echo "EXTONEOFFS_LABEL = $EXTONEOFFS_LABEL"
echo "EXTONEOFFS_LOCATION = $EXTONEOFFS_LOCATION"
echo "BIPB_LABEL = $BIPB_LABEL"
echo "BIPB_LOCATION = $BIPB_LOCATION"
echo "BIPB_HOST = $BIPB_HOST"
echo "FAPB_LABEL = $FAPB_LABEL"
echo "FAPB_LOCATION = $FAPB_LOCATION"
echo "FAPB_HOST = $FAPB_HOST"

if [ ! -d ${E2EPATH}/patches/${RELEASE}/P4FA/${P4FALABEL} ]; then
        mkdir -p ${E2EPATH}/patches/${RELEASE}/P4FA/${P4FALABEL}
        echo "Created path ${E2EPATH}/patches/${RELEASE}/P4FA/${P4FALABEL}"
else
        echo "Path ${E2EPATH}/patches/${RELEASE}/P4FA/${P4FALABEL} already exists"
fi

脚本不执行if-else中的所有语句,并提供以下输出:

NumberOfPods = 2
MC_HOST = host.com
MC_ROOT_USER = toor
MC_ROOT_PSWD = toor
LBOX_USER = user1
LBOX_HOST = host.com
RELEASE = 11
E2EPATH = /admin/sustenance/E2E_M4_PC6
P4FALABEL = PATCHES4FA_11.1.11.1.0ONEOFFS.1.S
P4FA_LOCATION = /autofs/gd14/160308.0946.1.S/patches4fa/dist
EXTONEOFFS_LABEL = PATCHES4FAEXTONEOFFS_PLATFORMS_160321.1032.S
EXTONEOFFS_LOCATION = /autofs/gd14/PATCHES4/patches4fa/dist/rel111extoneoffs
BIPB_LABEL = bi_rel11
BIPB_LOCATION = /scratch/saaspb/rel11.tar.gz
BIPB_HOST = host.com
FAPB_LABEL = gsi_rel11
FAPB_LOCATION = /scratch//erp/gsi_rel11.tar.gz
FAPB_HOST = host.com
 already existsA_11.1.11.1.0ONEOFFS.1.S

它不检查目录是否存在,也不执行mkdir命令。 该目录不存在,但显示已存在,标签名称的一半 好像它在脚本中执行了最后一个echo语句,而且部分

需要帮助来解决它

0 个答案:

没有答案