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.
If you are able to reproduce the problem, when running the script in console window, check the script output for any errors.
In the example below you can see that although the connection and file transfer finishes successfully, the attempt to set script option
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:  firstname.lastname@example.org Unknown value 'yes' of option 'confirm'. index.php | 5 KiB | 115,6 KiB/s | binary | 100%
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:  email@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
Note that the log (being associated with a session) would not record error that occurs before a session starts (such as when the failing
option command would precede the
open command). In this case use the previous approach of inspecting script output.
Site design by Black Gate