gpt4 book ai didi

linux - 嵌套的 Shell 脚本

转载 作者:太空宇宙 更新时间:2023-11-04 09:49:04 25 4
gpt4 key购买 nike

shell脚本中的以下代码有什么问题:

下面的代码引发了意外的 else 错误:

if [ $result -eq 0 ];
then
echo "SFTP completed successfully to Prod Remote Server" >> $LOG_FILE
else
errorConnectToProd=1
if [[ $result -eq 4 || $result -eq 5 ]];
echo "FAILED to connect to Server. " >> $LOG_FILE

else
echo "FAILED to SFTP to Remote Server. " >> $LOG_FILE
fi
fi

下面给出/usr/bin/sftp not found 错误:

/usr/bin/sftp –v -oPort=$SFTP_PORT -b $SFTP_BATCH_FILE $SOURCE_FUNCTIONAL_ID@$REMOTE_SERVER_PROD >> $LOG_FILE 2 >> $LOG_FILE

问候,

最佳答案

您在第二个 if 语句之后缺少 then

应该是

 if [[ $result -eq 4 || $result -eq 5 ]];
then
echo "FAILED to connect to Server. " >> $LOG_FILE

至于第二个命令,要么没有安装 sftp,要么它不在 /usr/bin 中。

运行 which sftp 找出它的位置。

关于linux - 嵌套的 Shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13100251/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com