Connection failed not returning an error code

Advertisement

ecommer
Joined:
Posts:
2
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
Joined:
Posts:
28,658
Location:
Prague, Czechia

Re: Connection failed not returning an error code

Please attach a log file.

Reply with quote

Advertisement

You can post new topics in this forum