WinSCP.com does not show Exit Code

Advertisement

Ivangi
Joined:
Posts:
2

WinSCP.com does not show Exit Code

Hi
I'm using WinSCP version 5.19.5 in Windows 2016 and when I launch WinSCP.com from CMD command line, it does not return last two lines indicating "Exit Code" and "Max roundtrip". I launch this command:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /script="D:\Scripts\PruebaWinSCP.txt"
Version 5.17.10 is the last one on which it worked fine.
How can I recover the Exit code in WinSCP.com output?

Regards

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
36,736
Location:
Prague, Czechia

Re: WinSCP.com does not show Exit Code

WinSCP outputs those lines on log level Debug 1 and higher only. I do not think this has changed between 5.17.10 and 5.19.5. You are probably using the "Normal" (default) logging level with your 5.19.5 installation. After all, your command-line does not set the logging level at all.

Anyway, you should not rely on those lines of output. They are for debugging only. Use the actual exit code.
https://winscp.net/eng/docs/faq_script_result

Reply with quote

Ivangi
Joined:
Posts:
2

Hi Martin
As you mentioned, in version 5.17.10 if you specify logging level higher than 0 it shows "Exit code" and "Max roundtrip", but on any higher version it doesn't (it writes this info in log file, but not in standard output).
I'll try to get actual exit code, but I launch WinSCP from another executable, and it's not so easy to obtain that.
Regards

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
36,736
Location:
Prague, Czechia

You actually need to have logging enabled to get this output. Setting logging level is not enough on its own. So this produces those lines:
WinSCP.com /ini=nul /command "exit" /loglevel=1 /log=winscp.log
I do not think there's any difference between 5.17.10 and 5.19.5 in this respect. You probably have logging enabled in 5.17.10 GUI. And as you do not isolate your script from the GUI configuration (/ini=nul in my example), it affects the script output. While in 5.19.5 you probably do not have logging enabled.

In any case, in all APIs I know, it's always easier to collect a process exit code than collecting and parsing the process output. You should not rely on parsing it. It's a debugging information. Its format can change in future.

Reply with quote

Advertisement

You can post new topics in this forum