Connection failed not returning an error code

Advertisement

ecommer
Joined:
Posts:
4
Location:
United States

Connection failed not returning an error code

I don't seem to getting an error code when the SFTP connection fails. (Server blocked me)
Script seems to work find otherwise - for example bad password etc.

Can someone please help me catch this error so that if it doesn't connect the batch file sees the error code.

script
# start script code 
open sftp://myun:cfgfdgfdg9R@mysite.com
option transfer binary
cd pim 
put \\Shares\Web\ItemUpdated\*.xml -preservetime
close 
exit

my_bat
"C:\Program Files (x86)\WinSCP\WinSCP.com" /console /script=C:\my_script.txt /log="C:\FileUpload\log\transfer.log" /logsize=5*10M

if %ERRORLEVEL% neq 0 goto error
 
echo Upload succeeded, moving local files to archive
move \\Shares\Web\ItemUpdated\*.xml \\Shares\Web\ItemProcessed
echo Removing any archive files older than 30 days
FORFILES /p "\\Shares\Web\ItemProcessed" /d -30 /m *.xml /c "cmd /c del @file"
exit 0

:error
echo Upload failed, keeping local files
exit 1

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Log file looks all good. And I cannot reproduce your problem. It works just fine for me with your batch file. What version of Windows are you using?

Reply with quote

Advertisement

ecommer

Windows Server 2012 R2 which is similar to Windows 10. We had a host blocking our ip which is when we noticed this. Otherwise yes it works fine on failed logins, etc.. weird. Thanks for looking into it

Reply with quote

martin
Site Admin
martin avatar

I'm sending you an email with a development version of WinSCP to the address you have used to register on this forum.

With /loglevel=1, it prints its exit code on output. Please test it, to see what WinSCP believes its exit code is.

Reply with quote

Advertisement

You can post new topics in this forum