Topic "Reset errors in scripted operation"

Author Message
dcstar
[View user's profile]

Joined: 2006-03-23
Posts: 3
Hello there, I have managed to successfully get a scripted job running, but I need to either have it ignore a possible error early in the script, or I need to be able to only capture errors later in the script.

I am creating a specific remote directory as part of the script - I don't really care if the directory already exists - but if the directory does exist, the resulting error returns an Errorlevel 1 when the script exits (it works fine if the directory doesn't exist).

I only want the Errorlevel 1 if subsequent file transfers fail!

It has to be this way as a separate process re-runs the script an hour later if it initially returned an error.

I think I can do a "workaround" by running two separate scripts, one to create the directory (without any error checking) and then one to do the transfers, but I'd rather have it all in one script for simplicity's sake.

I am using version 3.7.6 in a Windows XP environment.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
dcstar wrote:
I am creating a specific remote directory as part of the script - I don't really care if the directory already exists - but if the directory does exist, the resulting error returns an Errorlevel 1 when the script exits (it works fine if the directory doesn't exist).

I only want the Errorlevel 1 if subsequent file transfers fail!

The script should exit after error, only if you have "option batch abort" set. Do you? Then unset it before creating the directory, and reset it back afterwards:
Code:

...
option batch on
mkdir <path>
option batch abort
put ...

_________________
Martin Prikryl
dcstar
[View user's profile]

Joined: 2006-03-23
Posts: 3
prikryl wrote:
dcstar wrote:
I am creating a specific remote directory as part of the script - I don't really care if the directory already exists - but if the directory does exist, the resulting error returns an Errorlevel 1 when the script exits (it works fine if the directory doesn't exist).

I only want the Errorlevel 1 if subsequent file transfers fail!

The script should exit after error, only if you have "option batch abort" set. Do you? Then unset it before creating the directory, and reset it back afterwards:
Code:

...
option batch on
mkdir <path>
option batch abort
put ...

The issue isn't the script exiting with the abort option, the issue is when the script ends after successful file transfers, a previous mkdir failure returns errorlevel 1.

I had hoped that using additional "option abort" commands would reset the returned errorlevel in the script back to 0, but this doesn't seem to occur.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Sorry, Ive missed that. Then you need to make two scripts.
_________________
Martin Prikryl
dcstar
[View user's profile]

Joined: 2006-03-23
Posts: 3
No worries, I have gone in the dual scripts direction (though it would be nice to have a feature in the next version to reset the errorlevel..........) Wink
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