Error 4

Advertisement

CCS_ZA
Joined:
Posts:
2
Location:
South Africa

Error 4

Hi,
Whenever I try to drag and drop (or use a bat file) to copy over a 10mb .xlsm file using WinSCP only a part of the file copies over (varying size between 2mb to 8 mb) I get Error code: 4

As far I as I can tell this is not due to:
- Renaming a file to a name of already existing file - I've made sure an existing file with the same file does not exist
- Uploading to a full file system/exceeding disk quota - If I try to upload the file using FileZilla I do not get any issue so surely disk space or user disk quota cannot be an issue?

The strangest of all is when I execute a bat file to upload the file from windows task scheduler it SOMETIMES works and sometimes not. I've tried running WINSCP and the bat file "as administrator" so I don't think this is a permissions thing.

Any other fixes I can try?

Thanks!

EDIT: interestingly I noticed in FileZilla the upload fails once or twice sometimes but FileZilla automatically retries and uploads the file on the second or third time. This is the error FileZilla gives before going ahead:
Error: error while writing: received failure with description 'Failure'
Error: File transfer failed after transferring 6 717 440 bytes in 6 seconds

EDIT2: Uploaded log file

Reply with quote

Advertisement

CCS_ZA
Joined:
Posts:
2
Location:
South Africa

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!

Reply with quote

Advertisement

You can post new topics in this forum