Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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.
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
martin

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?
ecommer

Did the log file help any? We aren't sure how to resolve this issue.
ecommer

Hello Martin, I've attached a log for your review. Thanks
martin

Re: Connection failed not returning an error code

Please attach a log file.
ecommer

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