Why is WinSCP returning non zero exit code?

When checking results of your script you may encounter non zero exit code, indicating error, for reason that may not be obvious to you.

Sometimes the exit code indicates error even, when you consider outcome of the script successful. This is usually caused by a syntax error in the script command that is not essential for the overall script task.

Inspecting Script Output

If you are able to reproduce the problem, when running the script in console window, check the script output for any errors.

Advertisement (追記) (追記ここまで)

In the example below you can see that although the connection and file transfer finishes successfully, the attempt to set script option confirm to yes (instead of valid on) is the reason, why script exits with code 1 nevertheless.

Searching for host...
Connecting to host...
Authenticating...
Using username "martin".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] martin@example.com
Unknown value 'yes' of option 'confirm'.
index.php | 5 KB | 115,6 KB/s | binary | 100%

Inspecting Log File

If you are not able to reproduce the problem, when running the script in console window, at least try to enable session logging, e.g. using /log command-line parameter. Once the script finishes, search the generated log file for message “Script: Failed”, which should immediately follow the cause of the problem.

...
. 2010年11月27日 20:45:09.849 Getting current directory name.
. 2010年11月27日 20:45:09.849 Startup conversation with host finished.
< 2010年11月27日 20:45:09.849 Script: Active session: [1] martin@example.com
> 2010年11月27日 20:45:09.849 Script: option confirm yes
< 2010年11月27日 20:45:09.849 Script: Unknown value 'yes' of option 'confirm'.
. 2010年11月27日 20:45:09.850 Script: Failed
> 2010年11月27日 20:45:09.850 Script: put index.php
. 2010年11月27日 20:45:09.850 Copying 1 files/directories to remote directory "/home/martin/public_html"
...
. 2010年11月27日 20:46:12.738 Script: Exit code: 1

Advertisement (追記) (追記ここまで)

Last modified: by martin

AltStyle によって変換されたページ (->オリジナル) /