Replace FTP -s:E:\FtpScript.txt with SFTP?

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
aaronrb
Posts: 1
Joined: 13 Jan 2014 15:27

Replace FTP -s:E:\FtpScript.txt with SFTP?

#1 Post by aaronrb » 13 Jan 2014 15:58

I have the following Windows script that connects to a regular FTP server and downloads files.

However, the files have since been moved to an SFTP server. How can I modify the following script so that it connects to this new secure ftp server? I really don't want to modify too much since it had been working correctly with the past FTP server.

The ftp client I'm using here is the one that's included with Windows.

Thanks.

I'm including the script:

I have a Windows task that runs the following: ftp -s:C:\files\FtpScript.txt

FtpScript.txt has the following contents:

open web.myserver.com 8021
username
password
lcd /Data/2014/0113
prompt
get /var/opt/Data1200.xml
get /var/opt/Data1300.xml
get /var/opt/Data1400xml

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

Re: Replace FTP -s:E:\FtpScript.txt with SFTP?

#2 Post by Squashman » 13 Jan 2014 17:16

download psftp from the putty website.

julesverne
Posts: 81
Joined: 19 Nov 2013 00:41

Re: Replace FTP -s:E:\FtpScript.txt with SFTP?

#3 Post by julesverne » 13 Jan 2014 18:10

I do like putty and use it for other things. My sysadmin has us use WinSCP. So this is what I've come up with for automatic single file uploading in bat scripts

Code: Select all

START "secureftpmp4upload" /MIN /WAIT c:\winscp\winscp.exe /console /command "option batch continue" "open sftp://%login%:!pass!@%ftphost%:22" "put ""%uploadfolder%!$file!"" %serverhomedirectory%/%folderonserver%/!$file!" "close" "exit"


description of the variables
%login% = ftp login name
!pass! = password
%ftphost% = ftp server name or ip
22 is the typical port for sftp

%uploadfolder% = local folder path to the file that will be ftp'd
!$file! = the file to be ftp'd

%serverhomedirectory% = home directory on the server
%folderonserver% = folder and/or subfolders on the directory the file will be put on the server
!$file! = the file to be ftp'd

Post Reply