Scripting feature

Advertisement

M. Rusu
Guest

Scripting feature

Hello,

I would like to suggest implementing an enhanced scripting error handling. I want to be able for example to tell if an OPEN sftp command was successful or not.

This especially is very critical in our corporate environment. Let me explain why: if an user password has expired and he /she keeps trying to connect to the remote UNIX directory using our VB.net application, then the account locks and it may take a couple of days to unlock it. There are many steps to execute in the code, like moving, renaming files, etc. Not all of these steps can be checked for successful execution. I want to be able to stop execution at any time and display a meaningful error message.
It would be very useful to be able to display a message like "Authentication failed" or similar if an OPEN sftp command fails and also for every single WINSCP scripting command.

Best regards,
M.R. - Toronto

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Scripting feature

If you use "option batch abort", the scripts stops on any error and you can handle the situation as you like.

Reply with quote

Guest

Thank you for your answer.
I have set 'Option Batch Abort' in the VB.Net procedure but bothing happens if there is an error connecting to Unix. Execution just continues.

Here is my VB.Net code:

With oWinscp
' Feed in the scripting commands
.StandardInput.WriteLine("option batch abort")
.StandardInput.WriteLine("option confirm off")

'connect to Oracle directory
.StandardInput.WriteLine("open sftp://...user, password ...."
end with
more scripting commands....

How can I trap the error in VB.net if let's say the password is expired?

Regards,
M. Rusu

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

I wasn't able to reproduce your problem.

What version of WinSCP are you using?

If you have the latest one, create simple script file with:
option batch abort
option confirm off
open ....
put ....

Run the script and post the output of the script.

Reply with quote

M.R.
Guest

Scripting in VB.Net

Hello,
Sorry for the late reply. I am using ver. 4.2.6
I think some clarification is needed. When I mentioned that 'execution continues' I was referring to execution of scripting commands in a VB.Net procedure. . I would like to have a way in Visual Basic.Net to trap errors that may occur in scripting and stop the execution at any point in my procedure...
Something like a 'return code' or maybe to have a complete error description in the xml log file.

Regards,
M. Rusu

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum