Topic "Error in "call" does not abort the script"

Author Message
ZS

Guest


Hi,

I'm using a script to upload a zip file, unzip it, and delete the zip file - all through an SFTP connection.

I noticed that the script does not abort if the call to the unzip command fails.

I would expect that the script below would abort because of the "call false" and will never execute the "call echo ..." command.

Code:
open some_sftp_site.org
call false
call echo WinSCP did not abort
exit

However, the script continues regardless of the failure of the first "call" command.

From the log file, it is clear that WinSCP.com recieves the error status of the failing "call":
Code:
< 2015-08-04 07:27:06.066 Script: Session started.
. 2015-08-04 07:27:06.067 Executing user defined command on command session.
> 2015-08-04 07:27:06.067 [Shell] false ; echo "WinSCP: this is end-of-file:$?"
< 2015-08-04 07:27:06.138 [Shell] WinSCP: this is end-of-file:1
> 2015-08-04 07:27:06.138 [Shell] pwd ; echo "WinSCP: this is end-of-file:$?"
< 2015-08-04 07:27:06.210 [Shell] /home/osm
< 2015-08-04 07:27:06.210 [Shell] WinSCP: this is end-of-file:0
. 2015-08-04 07:27:06.210 Cached directory change via "/home/osm" to "/home/osm".
. 2015-08-04 07:27:06.210 Getting current directory name.
. 2015-08-04 07:27:06.210 Getting current directory name.
> 2015-08-04 07:27:06.211 Script: call echo WinSCP did not abort
. 2015-08-04 07:27:06.211 Executing user defined command on command session.
> 2015-08-04 07:27:06.211 [Shell] echo WinSCP did not abort ; echo "WinSCP: this is end-of-file:$?"
< 2015-08-04 07:27:06.283 Script: WinSCP did not abort
< 2015-08-04 07:27:06.283 [Shell] WinSCP did not abort
< 2015-08-04 07:27:06.283 [Shell] WinSCP: this is end-of-file:0

Is there a way to abort the script after a call fails?

Thanks!
Advertisements
SZ

Guest


The script contained "option batch abort":
Code:
option batch abort
open some_sftp_site.org
call false
call echo WinSCP did not abort
exit
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
WinSCP is rather tolerant to exit code 1 as many commands return is just as a warning. Use some if condition to turn 1 to 2.
Guest




I've been working with Unix and Linux for years, and I'm not aware of such an interpretation of exit status 1 as a warning. It is also not in line, for example, with the BASH Exit Codes documentation. See "Are there any standard exit status codes in Linux?" on StackOverflow for an extended discussion.

Morever, transforming exit status 1 to 2 in the remote machine is not very simple, and may depend on the login shell of the specific remote host.

Given the above, please reconsider the current behavior of WinSCP or provide a way set WinSCP to treat exit code 1 as a failure.

Thanks in advance!
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