Topic "Errorlevel not as expected"

Author Message
MajorTom2004
[View user's profile]

Joined: 2013-12-12
Posts: 3
Location: Switzerland
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
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
First, your use of WinSCP is not supported. You should not combine scripting and opening session using command-line argument. You should use open command from the script.
See http://winscp.net/eng/docs/commandline

Second, you should really upgrade.

Anyway, to investigate your problem, just turn on logging using /log=log_path switch. If the problem is not obvious, please attach a full log file here.
_________________
Martin Prikryl
MajorTom2004
[View user's profile]

Joined: 2013-12-12
Posts: 3
Location: Switzerland
Hi Martin.

Thank you for your fast response. I'll check it out as suggested and come back then.

Thomas
MajorTom2004
[View user's profile]

Joined: 2013-12-12
Posts: 3
Location: Switzerland
Hi Martin.

The tests I've done are very promising, the problem was the winscp.com /console "PROFILE" call.
When I put it as "open PROFILE" into the script, it works ok and brings back exactly what I expect, with the version 4.4.0.

Thank you very much for your help

I wish you a merry christmas!

Thomas
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24530
Location: Prague, Czechia
Thanks for your feedback. I would still like to see a log file of your original setup though. Because the change you've done should not have an effect on the exit code.
_________________
Martin Prikryl
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