Topic "Exitcode reporting and no-user-prompting when using /console /script="

Author Message
DaveLane

Guest


First of all, I'm delighted to see scripting support in WinSCP! Since I'm calling it from my own program, it would be very useful for it to (have an option to):

- not wait for user input when an error occurs (just fail the operation)
- report the error via an ExitCode that can be accessed by the calling program or batch file.

Thanks again for your efforts with WinSCP.

... Dave Lane
Nova Scotia Canada
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
DaveLane wrote:
- not wait for user input when an error occurs (just fail the operation)

When does this happen?
Quote:
- report the error via an ExitCode that can be accessed by the calling program or batch file.

I'll consider that, but it may be difficult to fit into current concept of the scripting.
_________________
Martin Prikryl
DaveLane

Guest


You asked: When does this happen?

Below is an example:

C:\Program Files\WinSCP3>winscp3 dlane@crux.stmarys.ca /console /script=test.txt

Initialisation...
Searching for host...
Connecting to host...
Authenticating...
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] dlane@crux.stmarys.ca
Host hasn't answered for 15 seconds.
Wait for another 15 seconds? Pressing 'Abort' button will close session.
(A)bort, (R)etry:

The script was:

cd /home/dlane/test
put file.txt
close
exit

In this case the script was cd'ing to a directory that did not exist. The user is prompted to abort or retry, but if a program is running the script it can't reply to it, it just hangs. The same occurs if other "errors" occur during the process.

You wrote: I'll consider that, but it may be difficult to fit into current concept of the scripting.

My concept of scripting is to allow the scp process to be automated by other programs (without human intervention) and in this scenario there would have to be some way to know if the operation succeeded or failed.

Cheers, Dave
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
If you read the error message carefully, you would that your server does not reply. So there is some other problem. I do not know what. Do you have the problem even in GUI (graphical) mode? Can you post a log file?

Even when you process the script file, you can still reply the prompts. I do not know why WinSCP hangs in your case. Are you running the script using winscp3.exe or winscp3.com?

You can avoid prompts at all using "option batch on", but it will not probably help in your case.
_________________
Martin Prikryl
DaveLane

Guest


prikryl wrote:
If you read the error message carefully, you would that your server does not reply. So there is some other problem. I do not know what. Do you have the problem even in GUI (graphical) mode? Can you post a log file?


The 'option batch on' command solved my problem of the user prompts. The example that I gave you intentionally had an error in it so that a user-prompt would be shown. When no error occurs winscp3 works flawless for me.

My trouble with using 'set batch on' is that I have no way of knowing if my transfer was successful or not. I supposed I could try parsing the

As mentioned earlier, the ideal solution would be setting the exit code to 0 if no error occurred or 1 is any error occurred.

Cheers,

Dave

ps. I was using winscp3.exe (although winscp3.com acts the same).
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
DaveLane wrote:
My trouble with using 'set batch on' is that I have no way of knowing if my transfer was successful or not. I supposed I could try parsing the

As mentioned earlier, the ideal solution would be setting the exit code to 0 if no error occurred or 1 is any error occurred.

OK, I may return exit code 1 if any prompt during script execution was answered "abort" (even automatically because of 'option batch on'). But I suppose you would rather have the script stopped once such event occures, wouldn't you?
_________________
Martin Prikryl
DaveLane

Guest


prikryl wrote:

OK, I may return exit code 1 if any prompt during script execution was answered "abort" (even automatically because of 'option batch on'). But I suppose you would rather have the script stopped once such event occures, wouldn't you?


Actually that would be perfect for my purposes since I only upload one file (a zip file) per session. Thanks for including this new feature in V3.7.1 - much appreciated. I've tested it and it works perfectly.

My application is an astronomical observatory automation program which includes a feature to upload the night's images to a server at the end of the night.

Regards, Dave
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