透過 SFTP 連線收到「沒​​有此類檔案或目錄」訊息,但檔案位於伺服器上

透過 SFTP 連線收到「沒​​有此類檔案或目錄」訊息,但檔案位於伺服器上

我正在試圖弄清楚,我想知道你們中的一些人以前是否經歷過這種情況。

我有我的 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

謝謝!

相關內容