Topic "Trouble automating winscp.com with Public Key"

Author Message
Mike250
[View user's profile]

Joined: 2013-07-24
Posts: 3
Location: Sydney, Australia
Hi there,

I am connecting to a client SFTP via shared Public Key (*.ppk) which I am successfully performing via the current WinScp.exe and Winscp.com. I have verified connectivity by putting and getting files both in the GUI and command line.

What I can't seem to do is automate the put of files from the command line. If I perform the following steps, one by one, at the command line, I am successful:
Code:

cd \program files (x86)\winscp\
winscp.com /command "open myuser@files.myclient.net" /privatekey=C:\Export\Scripts\20130620.ppk
put C:\Export\Archive\*.zip upload/
close
exit


So, I created a batch file to perform this task, which connects and authenticates to the SFTP site just fine, but it does not perform the put. I have the winscp> prompt but nothing after that. See the connection log below.

Code:

Searching for host...
Connecting to host...
Authenticating...
Using username "myuser".
Authenticating with public key "20130620".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] myuser@files.myclient.net
winscp>


It just sits there. If I now manually enter put C:\Export\NoniB\Archive\*.zip upload/ the file will upload. I can't seem to get it to perform automatically. Any thoughts? Thank you in advance.
Advertisements
Mike250
[View user's profile]

Joined: 2013-07-24
Posts: 3
Location: Sydney, Australia
Let me add, I have also tried this approach.

sftp.bat
Code:

cd \program files (x86)\winscp\
winscp.com scp://myuser@files.myclient.net /privatekey=C:\Export\Scripts\20130620.ppk /script=c:\export\scripts\sftp.txt


sftp.txt
Code:

option batch abort
option confirm off
put C:\Export\Archive\*.zip upload/
exit


Same problem. Connects, authenticates, Active session - but no put. Awaiting at the prompt winscp>.

Code:
Searching for host...
Connecting to host...
Authenticating...
Using username "myuser".
Authenticating with public key "20130620".
Authenticated.
Starting the session...
Reading remote directory...
Session started.
Active session: [1] myuser@files.myclient.net
winscp>


A bit baffled here, and have been digging through FAQ. I thank you kindly for any assistance.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24555
Location: Prague, Czechia
Your second approach was close. Though you should see following message as a very first line of an output (providing you are using a recent version of WinSCP):
Quote:
Automatic actions are disabled when URL address is provided on command-line.


You should do this:

Code:
cd \program files (x86)\winscp\
winscp.com /script=c:\export\scripts\sftp.txt /log=c:\export\scripts\sftp.log


sftp.txt:
Code:
option batch abort
option confirm off
open scp://myuser@files.myclient.net -privatekey=C:\Export\Scripts\20130620.ppk
put C:\Export\Archive\*.zip upload/
exit


See here for details:
http://winscp.net/eng/docs/guide_automation

Note that I've added a /log=. If you still cannot make this work, please attach the log (c:\export\scripts\sftp.log).
Mike250
[View user's profile]

Joined: 2013-07-24
Posts: 3
Location: Sydney, Australia
Thank you sir, I believe I have it.
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