How can I detect upload success/failure in a scripted command-line SFTP session
Posted
by
pkpk
on Server Fault
See other posts from Server Fault
or by pkpk
Published on 2012-11-21T03:02:51Z
Indexed on
2012/11/21
5:03 UTC
Read the original article
Hit count: 497
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%
© Server Fault or respective owner