Topic "Stored Sessions and SSH Keys"

Author Message
EricL

Guest


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.
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
I'm not able to reproduce the problem.
What version of WinSCP are you using? Can you post a script file causing the problem?
_________________
Martin Prikryl
EricL

Guest


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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
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

Guest


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
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
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.
_________________
Martin Prikryl
EricL

Guest


Ah, that make sense. Tested and it works perfectly. Thanks!
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