Topic "error code ??"

Author Message
landog
[View user's profile]

Joined: 2013-08-20
Posts: 3
Location: Cleveland
I have a batch file that runs a WinSCP script on a Windows box via a scheduled task.
The objective is to transfer the files via SFTP and then move the files to another folder. If the files fail to transfer, I do not want them to be moved.

The batch file:
Code:

cd \transfer
if exist *.txt GOTO run
exit
:run
winscp.com /script=transfer.scr /xmllog=C:\transfer\!S-!Y-!M-!D-!T.xml
IF NOT ERRORLEVEL 0 GOTO Fail
move *.txt c:\transferred
exit
:Fail

The transfer script:
Code:

option batch abort
option confirm off
option transfer ascii
open session
put *.txt
close
exit


One recent transfer failure resulted in this message in the XML log:
Code:

  <failure>
    <message>Network error: Connection refused.</message>
  </failure>

However, WinSCP must have returned with an exit of '0' - as the files were moved to the "transferred" folder.

Should WinSCP return with an error of '1' after the connection to the destination was refused?

Is there a better approach to get the behaviour I am seeking?
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
The if not errorlevel 0 never happens. Because if errorlevel 0 means if errorlevel >= 0 (read if /?). Hence your condition is the same as if errorlevel < 0, what is never true. Use if errorlevel 1, as all the examples on this site do.
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License