Page 1 of 1

I want to use secure FTP in a script

Posted: 19 Oct 2015 20:00
by born2achieve
Hi,

I have my vendor's ftp url over SSL. it's like ftps://myvendor.com and i have username and password. So please help me on writing batch script t o downlod the file from my vendor repository.
If this is not possible in dos script, please suggest me opensource tool. But i would love the solution in dos script as i need to use this forever to avoid any manual work.

Thanks

Re: Help Need in batch script

Posted: 19 Oct 2015 20:12
by Squashman
Windows ftp cannot do ftp with TLS or SSL.

I would look at using psftp or winscp. One of those should work.

Re: I want to use secure FTP in a script

Posted: 20 Oct 2015 16:09
by born2achieve
Hi Squashman,

thanks for your reply. Here is my try

I tried to make below code with the file name as "connection.txt"

Code: Select all

# Automatically abort script on errors
option batch abort
# Disable overwrite confirmations that conflict with the previous
option confirm off
# Connect with username and password
open sftp://username:pwd: https://ftps.domain.com/
# Change local directory
lcd D:\Test\FTPS\
# Force binary mode transfer
option transfer binary
# Download missing files to local directory from remote
get “*.*” .\
# Disconnect
close
# Exit WinSCP
exit



in the place of username,pwd,url i supplied my actual values. Also i am trying to download all the file as a test and used *.* ./

Then i called the winscp exe using below code

Code: Select all

D:\Test\winscp570\WinSCP.exe /console /script="D:\Test\winscp570\connection.txt" /log="D:\Test\winscp570\conn.log"


Is there anything am doing wrong? please help me on giving the workable script.

Thanks

Re: I want to use secure FTP in a script

Posted: 20 Oct 2015 16:35
by Squashman
I have never used either one. I just know what they can do.

But it looks to me like you are mixing protocols. This makes no sense at all.

Code: Select all

open sftp://username:pwd: https://ftps.domain.com/

Re: I want to use secure FTP in a script

Posted: 21 Oct 2015 03:41
by penpen
Based on the official WinSCP documentation, i would guess the open line should look like this:

Code: Select all

open sftp://username:pwd@ftps.domain.com/


penpen