我正在试图弄清楚,我想知道你们中的一些人以前是否经历过这种情况。
我有我的 SFTP 脚本(之前是 FTP,后来迁移到 SFTP),当我向客户端服务器发送文件时,我收到一条消息“没有这样的文件或目录”,但该文件已打开客户端服务器。以前当我有 FTP 连接时不会发生这种情况。
你们中有人以前经历过这种情况吗?即使我以状态 0 退出,这对我来说也很奇怪......
debug1: Couldn't stat remote file: No such file or directory
debug1: Couldn't stat remote file: No such file or directory
debug1: channel 0: read<=0 rfd 6 len 0
debug1: channel 0: read failed
debug1: channel 0: close_read
debug1: channel 0: input open -> drain
debug1: channel 0: ibuf empty
debug1: channel 0: send eof
debug1: channel 0: input drain -> closed
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: rcvd close
debug1: channel 0: output open -> drain
debug1: channel 0: obuf empty
debug1: channel 0: close_write
debug1: channel 0: output drain -> closed
debug1: channel 0: almost dead
debug1: channel 0: gc: notify user
debug1: channel 0: gc: user detached
debug1: channel 0: send close
debug1: channel 0: is dead
debug1: channel 0: garbage collecting
debug1: channel_free: channel 0: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
debug1: fd 2 clearing O_NONBLOCK
debug1: Transferred: stdin 0, stdout 0, stderr 0 bytes in 4.6 seconds
debug1: Bytes per second: stdin 0.0, stdout 0.0, stderr 0.0
debug1: Exit status 0
代码:
当然,我有这个:
sftp -v -b ${sftp_file} ${username}@${server} > ${tmplog1} 2>&1 > ${tmplog2}
GetStatus=$?
if (( $GetStatus != 0 )); then
if [[ $(grep -c "No such file or directory" ${tmplog1}) > 0 ]]; then
ErrorMessage="No such file or directory"
elif [[ $(grep -c "Connection refused" ${tmplog1}) > 0 ]]; then
ErrorMessage="Connection refused with the server"
elif [[ $(grep -c "Connection timed out" ${tmplog1}) > 0 ]]; then
ErrorMessage="Connection timed out with the server"
elif [[ $(grep -c "No route to host" ${tmplog1}) > 0 ]]; then
ErrorMessage="No route to the server."
else
ErrorMessage="Unknown Error in transmission process."
fi
fi
谢谢!