Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

EricL

Ah, that make sense. Tested and it works perfectly. Thanks!
martin

OK, now it is obvious. In the first example you open the session from command line, before the script gets started, so the batch mode is not enabled yet. In the second example, you open the session from script after you enable the batch mode.

Replace <user>@<site>:<port> with <profilename> in your second example to make it work.
EricL

Sorry, I posted the incorrect script layout for what the example was - when I use a stored session with the winscp.exe command, I do not include the open/cd commands. It actually looks like:

(This is the example that does NOT auto decline.)

"C:\Program Files\WinSCP\WinSCP.exe" "<profilename>" /console /script=<script path & filename>

option batch ON
option confirm off
option transfer binary
get <filename>
close
exit

...where the open parameters (site/port/user/pass) and the directory are configured in the session.

What I posted earlier is what I would use if I am not using a stored session, I am adding the open command parameters to the script and running the command as:

(This is the example that DOES auto decline.)

"C:\Program Files\WinSCP\WinSCP.exe" /console /script=<script path & filename>

option batch ON
option confirm off
open <user>@<site>:<port>
cd <directory>
option transfer binary
get <filename>
close
exit
martin

When you say you do not use stored session, what do you change? Do you change <profilename> on command line to something like <user>@<site>:<port>?

Please note that in what you have posted, there are actually two sessions opened. One from command line by <profilename> and the other by "open" command in the script. Is that intentional? For which of the sessions do you get the prompt?
EricL

WinSCP Version 4.1.6 (Build 412)

Like I said, the program executes correctly when not using a stored session, so I do not believe there is an issue with the script, but here it is the way it is layed out:

option batch ON
option confirm off
open <user>@<site>:<port>
cd <directory>
option transfer binary
get <filename>
close
exit

And the program is executed from the command line as:

"C:\Program Files\WinSCP\WinSCP.exe" "<profilename>" /console /script=<script path & filename>
martin

Re: Stored Sessions and SSH Keys

I'm not able to reproduce the problem.
What version of WinSCP are you using? Can you post a script file causing the problem?
EricL

Stored Sessions and SSH Keys

I've tried looking on the forums and in help docs for any info on this and I haven't seen it, so I thought I'd ask.

I am trying to do three things:
1. Use a batch file that auto-creates a script of particular functions when transfering a file.
2. Use a stored session configured in the GUI application so that I do not have to dual-maintain the GUI application session and the connection details in the bat file.
And these two things work fine, except for the third thing I want to do:
3. Auto-decline accepting a new SSH key (as it should when "option batch on" is specfied).

Every time I try to use a stored session, it always stays on the Yes/No/Cancel/Save prompt until I manually select a choice, whereas if I do not specify a stored session and add the connection details into the script it does not stay on the prompt and automatically answers negatively, like I want.

Am I missing an option to be configured in the stored session for this? Or any other explanation? Thanks for any help.