How can I detect upload success/failure in a scripted command-line SFTP session
- by pkpk
how can I detect success/failure sftp Batch script on Windows OS?
I use %errorlevel% to detect success/failure, sometime the %errorlevel% be returned by 0, but that session is fail and the file is not upload to the server. my script is below
how can I detect sftp uploaded correctly? THX so much
@echo off
(echo cd %4
echo put %2
echo exit)>sftpScript.txt
sftp -b sftpScript.txt %3
set result=%errorlevel%
if result EQU 0 (
del sftpScript.txt
del %2
) else (
del sftpScript.txt
)
exit %result%