So it seems like there is packet loss between the local and remote destination for some reason. I got it working with the following hack:
@echo off
set TRIES=10
set INTERVAL=3
:retry
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Users\Administrator\Documents\XXX\WinSCP.log" /ini=nul ^
/command ^
"open sftp://XXX="" -privatekey=""C:\Users\Administrator\Documents\XXX\XXX.ppk""" ^
"lcd C:\Users\Administrator\Documents\XXX" ^
"cd ""/XXX/XXX""" ^
"option batch continue" ^
"rm XXX.xlsm" ^
"put XXX.xlsm" ^
"exit" ^
if %ERRORLEVEL% neq 0 (
set /A TRIES=%TRIES%-1
if %TRIES% gtr 1 (
echo Failed, retrying in %INTERVAL% seconds...
timeout /t %INTERVAL%
goto retry
) else (
echo Failed, aborting
exit /b 1
)
)
echo Success
exit /b 0
Basically I keep retrying to upload until the partial file is complete. Not sure how robust this will be going forward, please let me know if you have a better solution!
@echo off
set TRIES=10
set INTERVAL=3
:retry
"C:\Program Files (x86)\WinSCP\WinSCP.com" ^
/log="C:\Users\Administrator\Documents\XXX\WinSCP.log" /ini=nul ^
/command ^
"open sftp://XXX="" -privatekey=""C:\Users\Administrator\Documents\XXX\XXX.ppk""" ^
"lcd C:\Users\Administrator\Documents\XXX" ^
"cd ""/XXX/XXX""" ^
"option batch continue" ^
"rm XXX.xlsm" ^
"put XXX.xlsm" ^
"exit" ^
if %ERRORLEVEL% neq 0 (
set /A TRIES=%TRIES%-1
if %TRIES% gtr 1 (
echo Failed, retrying in %INTERVAL% seconds...
timeout /t %INTERVAL%
goto retry
) else (
echo Failed, aborting
exit /b 1
)
)
echo Success
exit /b 0
Basically I keep retrying to upload until the partial file is complete. Not sure how robust this will be going forward, please let me know if you have a better solution!