I want to use secure FTP in a script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

I want to use secure FTP in a script

#1 Post by born2achieve » 19 Oct 2015 20:00

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

Squashman
Expert
Posts: 4141
Joined: 23 Dec 2011 13:59

Re: Help Need in batch script

#2 Post by Squashman » 19 Oct 2015 20:12

Windows ftp cannot do ftp with TLS or SSL.

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

born2achieve
Posts: 51
Joined: 16 Nov 2014 20:28

Re: I want to use secure FTP in a script

#3 Post by born2achieve » 20 Oct 2015 16:09

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

Squashman
Expert
Posts: 4141
Joined: 23 Dec 2011 13:59

Re: I want to use secure FTP in a script

#4 Post by Squashman » 20 Oct 2015 16:35

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/

penpen
Expert
Posts: 1786
Joined: 23 Jun 2013 06:15
Location: Germany

Re: I want to use secure FTP in a script

#5 Post by penpen » 21 Oct 2015 03:41

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

Post Reply