Errorlevel not as expected
Hello.
I use the WinSCP.com version 4.4.0, and there I found a behaviour, which is not transparent to me.
I test this version since I have the exact documented problem in Bug #953 in Version 4.3.2.
Here is what I do:
C:\temp> E:\FTP_Tools\WinSCP\WinSCP.com /console "PROFILE_NAME"
winscp> option batch abort
winscp> option confirm off
winscp> option transfer ASCII
winscp> cd /
winscp> get filename_exist.csv
winscp> close
winscp> exit
C:\temp> echo %errorlevel%
0
C:\temp>
This means, the session is opened correctly, the file is found and downloaded and WinSCP.com returns an errorlevel of "0"
Now, the "get line" is changed to "get filename_does_not_exist.csv", after finsishing the winscp executable, the errorlevel returned is "1".
This is exactly, what I expect, success returns a "0", error returns a "1".
In the next step, I write all the commands into a file called E:\FTP_Scripts\0099_wscp.scri instead of supplying them interactively,
the script-file looks like this:
option batch abort
option confirm off
option transfer ASCII
cd /
get filename_exist.csv
close
exit
and then I start the command with
C:\temp> E:\FTP_Tools\WinSCP\WinSCP.com /console "PROFILE_NAME" /script=E:\FTP_Scripts\0099_wscp.scri
After finishing, I also want to read the errorlevel with
C:\temp> echo %errorlevel%
Regardless of a successful end or not (file exists or not), I get the errorlevel "1" in every situation.
I have tried a lot of things, like
- set retcode=%errorlevel% and echo Returncode %retcode% in order to make sure that the value of the errorlevel is not overwritten
- try all winscp-options that could make sense or not, like option batch abort, option batch on, etc.
- put it all in a bat and start this with and without the call command.
- start the command from within the WinSCP-Folder or not
- . . .
Where am I wrong? Is this maybe a bug in WinSCP.com 4.4.0?
Thank you very much for your help.
Thomas
I use the WinSCP.com version 4.4.0, and there I found a behaviour, which is not transparent to me.
I test this version since I have the exact documented problem in Bug #953 in Version 4.3.2.
Here is what I do:
C:\temp> E:\FTP_Tools\WinSCP\WinSCP.com /console "PROFILE_NAME"
winscp> option batch abort
winscp> option confirm off
winscp> option transfer ASCII
winscp> cd /
winscp> get filename_exist.csv
winscp> close
winscp> exit
C:\temp> echo %errorlevel%
0
C:\temp>
This means, the session is opened correctly, the file is found and downloaded and WinSCP.com returns an errorlevel of "0"
Now, the "get line" is changed to "get filename_does_not_exist.csv", after finsishing the winscp executable, the errorlevel returned is "1".
This is exactly, what I expect, success returns a "0", error returns a "1".
In the next step, I write all the commands into a file called E:\FTP_Scripts\0099_wscp.scri instead of supplying them interactively,
the script-file looks like this:
option batch abort
option confirm off
option transfer ASCII
cd /
get filename_exist.csv
close
exit
and then I start the command with
C:\temp> E:\FTP_Tools\WinSCP\WinSCP.com /console "PROFILE_NAME" /script=E:\FTP_Scripts\0099_wscp.scri
After finishing, I also want to read the errorlevel with
C:\temp> echo %errorlevel%
Regardless of a successful end or not (file exists or not), I get the errorlevel "1" in every situation.
I have tried a lot of things, like
- set retcode=%errorlevel% and echo Returncode %retcode% in order to make sure that the value of the errorlevel is not overwritten
- try all winscp-options that could make sense or not, like option batch abort, option batch on, etc.
- put it all in a bat and start this with and without the call command.
- start the command from within the WinSCP-Folder or not
- . . .
Where am I wrong? Is this maybe a bug in WinSCP.com 4.4.0?
Thank you very much for your help.
Thomas