winscp3.com /console /script=f sftp://user1@server:1233

Advertisement

gmg
Guest

winscp3.com /console /script=f sftp://user1@server:1233

I have a batch script I want to run but can't seem to get it working.

When I pass the login thru the command-line, winscp3 logins but the script file isn't execute. If I don't pass in the login information the script file is execute. (the chicken or the egg)

winscp3.com /console /script=f sftp://user1@server:1233

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,518
Location:
Prague, Czechia

Re: winscp3.com /console /script=f sftp://user1@server:1233

You cannot combine "sftp://..."-like parameter with /script for security reasons. See documentation. Open the session from script instead.

Reply with quote

gmg
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

You cannot combine "sftp://..."-like parameter with /script for security reasons. See documentation. Open the session from script instead.

I have tried 'open sftp://<uid>:<pwd>@<server>' in the script and it failed to login. It not accepting the password. I have event tried typing the password in and it still does work. Do I need to do anything else for sftp?.

Reply with quote

gmg
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

Are you able to login from GUI?

No, it fails as well, the message I receive is below:

Authentication log (see session log for details):
Using username "<userid>".
GlobalSCAPE Secure FTP Server (v. 3.1)Authenticating with pre-entered password.
Access denied.
No supported authentication methods left to try!

Connection has been unexpectedly closed. Server sent command exit status 0.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: winscp3.com /console /script=f sftp://user1@server:1233

Are you able to login wih any other SFTP or SSH client?

Reply with quote

Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

Are you able to login wih any other SFTP or SSH client?

I'm able to login using your program, via command line.

Reply with quote

martin
Site Admin
martin avatar

Re: winscp3.com /console /script=f sftp://user1@server:1233

I'm able to login using your program, via command line.
Sorry, it does not make sense. Above you wrote that you are not.

Reply with quote

gmg
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

I'm able to login using your program, via command line.
Sorry, it does not make sense. Above you wrote that you are not.

1. sftp only works when I run it thru the command line:
winscp3.com sftp://<uid>:<pwd>@<server>

2. When I try to login thru a script file that has the open command it fails

scripts file....
option batch on
option confirm on
option transfer binary
open sftp://<uid>:<pwd>@<server>
get *
close
exit
3. If I try to login thru the ui and doesn't fails as well.

I'm only able to get the command-line to work.

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: winscp3.com /console /script=f sftp://user1@server:1233

Please post a log file showing successful connection with command-line parameter and failed one with "open" command.

Reply with quote

KDearing
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

You cannot combine "sftp://..."-like parameter with /script for security reasons. See documentation. Open the session from script instead.

I read the documentation and saw that but am left wondering how to handle this.. I need to do a simple get via automation (ie, sftp download)

My only thought at the moment is a big no-no (VB 'SendKeys'). I'm hoping that I'm just missing something..

Thanks in advance,

Kevin

Reply with quote

KDearing
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

gmg wrote:

martin wrote:

I'm able to login using your program, via command line.
Sorry, it does not make sense. Above you wrote that you are not.

1. sftp only works when I run it thru the command line:
winscp3.com sftp://<uid>:<pwd>@<server>

2. When I try to login thru a script file that has the open command it fails

scripts file....
option batch on
option confirm on
option transfer binary
open sftp://<uid>:<pwd>@<server>
get *
close
exit
3. If I try to login thru the ui and doesn't fails as well.

I'm only able to get the command-line to work.

Hey,
I'm hoping that you got this working - I did see in the documentation that it looks like it's not allowed for security reasons (which makes sense and all, but ...)

So, please let us know if and how you were able to get this to work. Thanks in advance,

Kevin

Reply with quote

martin
Site Admin
martin avatar

Re: winscp3.com /console /script=f sftp://user1@server:1233

KDearing wrote:

So, please let us know if and how you were able to get this to work. Thanks in advance,
I simply should work. So if you can tell what exactly is your problem...

Reply with quote

Advertisement

KDearing
Joined:
Posts:
2
Location:
PA, USA

Re: winscp3.com /console /script=f sftp://user1@server:1233

martin wrote:

KDearing wrote:

So, please let us know if and how you were able to get this to work. Thanks in advance,
I simply should work. So if you can tell what exactly is your problem...

Hi,
My problem is that I am trying to automate a simple download from a sftp server. I've been able to get it to open a console connection but the GET command (and any other commands I've tried) are simply not run. The console just sits there awaiting me to manually type the commands. This is in-line with what I read in the documentation.

I am not at my office so I don't have the actual scripts that I tried but I've been trying something like:

winscp.exe sftp://sftpuser@someserver.somehost.com:22 /privatekey=c:\kdearing\algo\test\pkey.pph /console /script=c:\kdearing\algo\test\download_test_001.txt


download_test_001.txt:

option batch on

option confirm off

cd /ftp/OUT

get somefilename.csv c:\kdearing\algo\test\

close

exit


I've also tried to put the open in the script like:

open sftp://sftpuser@someserver.somehost.com:22


but at that point I can't even get it to connect - well, the console window closes too quickly for me to see what's going on.

Furthermore I have not been able to get the /log
=c:\kdearing\algo\test\logfile.txt

to work (which also seems to be in-line with the documentation..)

--KDearing

Reply with quote

martin
Site Admin
martin avatar

Re: winscp3.com /console /script=f sftp://user1@server:1233

KDearing wrote:

but at that point I can't even get it to connect - well, the console window closes too quickly for me to see what's going on.
Run winscp.com instead from opened console (cmd.exe) to keep the results on screen.

Reply with quote

jvc714
Guest

Re: winscp3.com /console /script=f sftp://user1@server:1233

I'm having exactly the same problem.

I even tried to login using the consule and do a /command "PUT filename" it doesn't work.

I've tried the different combinations of the script file with no progress.

I've evern tried what I am not suppose to due to security like you said above and it still doesn't work.

I'm out of ideas and combinations to try. Is there a command for specifying the private key file in the script? I tried different combinations but unable to get it work either.

Thanks.
JT

Reply with quote

KDearing
Joined:
Posts:
2
Location:
PA, USA

Re: winscp3.com /console /script=f sftp://user1@server:1233

jvc714 wrote:

I'm having exactly the same problem.

Thanks to Prikryl's single comment of 'Use winscp3.com' I have gotten it working..

Here's the steps that I took (leaving out the stuff that didn't work of course! :D )

  • Ran WinSCP's Gui.
  • Set up a saved session..
  • Logged on and accepted the certificate
  • Closed the session.
  • Created a batch file with this line:
    "C:\program files\WinSCP\WinSCP.com"  algo /privatekey=C:\pathto\USE_THIS_PRIVATE_KEY.ppk /console /script=c:\pathto\today_script.txt /log=c:\pathto\daily_log.txt
  • Created the 'today_script.txt' as below
  • Done.. works perfectly!

Here's my today_script.txt file:

option batch on
option confirm off

open sftp://sftpuser@servername.com:22  /privatekey=C:\pathto\USE_THIS_PRIVATE_KEY.ppk

cd /ftp/OUT/

get somefile.csv C:\pathto\downloaded\

close

exit

THere may be extra stuff in there (like I probably only need to specify the private key once - if at all - I mean it's saved with the "algo" session..

Either way, awesome stuff!

--KTFA

Reply with quote

Advertisement

You can post new topics in this forum