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

BalajiKK

Re: Additionally

Hi

I am new to WinSCP/SFTP and I am struggling to automate the file transfer. The issue I have is that on top of Public Key (*.ppk), I have passphrase to use to establish the connection. Can someone please advise where to put the passphrase in these codes?

sftp.bat:
cd \program files (x86)\winscp\

winscp.com /script=c:\export\scripts\sftp.txt /log=c:\export\scripts\sftp.log


sftp.txt:
option batch abort

option confirm off
open scp://myuser@files.myclient.net -privatekey=C:\Export\Scripts\20130620.ppk
put C:\Export\Archive\*.csv
exit


Thanks
Balaji


martin wrote:

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):
Automatic actions are disabled when URL address is provided on command-line.


You should do this:

cd \program files (x86)\winscp\

winscp.com /script=c:\export\scripts\sftp.txt /log=c:\export\scripts\sftp.log


sftp.txt:
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:
https://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

Thank you

Thank you sir, I believe I have it.
martin

Re: Additionally

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):
Automatic actions are disabled when URL address is provided on command-line.


You should do this:

cd \program files (x86)\winscp\

winscp.com /script=c:\export\scripts\sftp.txt /log=c:\export\scripts\sftp.log


sftp.txt:
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:
https://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

Additionally

Let me add, I have also tried this approach.

sftp.bat
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
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>.

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.
Mike250

Trouble automating winscp.com with Public Key

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:
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.

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.