Error in shell: [!: Analysis solution of [!: command not found]

在 Shell 中报错:[!: command not found
1. Report an error in the shell:[!: command not found,如图1 [Caption id=”attachment_4126″ align=”alignnone” width=”1363″]#ATFP_CLOSE_Translate_span#在 Shell 中报错:[!: command not found Figure 1[/caption]


2020/5/6 下午2:56:57 PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH=/var/log/pcs
2020/5/6 下午2:56:57 /config/init/console_init.sh: line 40: [!: command not found
2020/5/6 下午2:56:57 running chown -R nginx:nginx /var/log/pcs
2020/5/6 下午2:56:57 /config/init/cronlog.sh: line 4: LOG_NAME: unbound variable
2020/5/6 下午2:56:58 Unlinking stale socket /var/run/supervisor/supervisor.sock


2. Edit /build/c_files/config/init/console_init.sh. at[]Add spaces before and after. as shown in Figure 2
编辑 /build/c_files/config/init/console_init.sh。在 [] 前后添加空格。
Figure 2


env | grep PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH || export PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH="/var/log/pcs"
if [[ $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH != "" ]]
then
    if [! -d $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH]
    then
        mkdir -p $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH
    fi
    chown -R nginx:nginx $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH
    echo "running chown -R nginx:nginx $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH"
else
    echo "please set environment variable PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH can not be empty"
fi




env | grep PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH || export PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH="/var/log/pcs"
if [[ $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH != "" ]]
then
    if [ ! -d $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH ]
    then
        mkdir -p $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH
    fi
    chown -R nginx:nginx $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH
    echo "running chown -R nginx:nginx $PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH"
else
    echo "please set environment variable PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH can not be empty"
fi


3. There is no error in the shell. And the error: unlinking stale socket /var/run/supervisor/supervisor.sock has also disappeared. as shown in Figure 3
在 Shell 中未再报错。且报错:Unlinking stale socket /var/run/supervisor/supervisor.sock 也已经消失。
Figure 3


2020/5/8 下午2:17:09 PCS_API_CFG_ACTION_LOG_ABSOLUTE_PATH=/var/log/pcs
2020/5/8 下午2:17:09 running chown -R nginx:nginx /var/log/pcs
2020/5/8 下午2:17:09 /config/init/cronlog.sh: line 4: LOG_NAME: unbound variable


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.