1

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.

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
Mark
  • 3,609
  • 1
  • 22
  • 33
  • Windows [ftp.exe](http://technet.microsoft.com/en-us/library/ff687787%28v=ws.10%29.aspx) does not support SFTP, AFAICT. – Ken White Jan 14 '14 at 01:13
  • I understand there are several ways of doing it; that wasn't the question. My question was if there's a way to use what I currently have without having to redo the whole thing. –  Jan 14 '14 at 15:10

1 Answers1

1

Windows command line FTP client does not support SFTP protocol.

You can switch to WinSCP:

  • replace your command line with:

    winscp.com /script=C:\files\FtpScript.txt
    
  • replace your connection and authentication commands with:

    open sftp://username:password@web.myserver.com/
    
  • the lcd can stay (though /Data/2014/0113 does not look like a local path)

  • in WinSCP the get needs a target path, use .\ to download to the local current working directory.
  • add the exit command

For details, see Secure FTP using Windows batch script or WinSCP guide for Converting Windows FTP script to WinSCP SFTP script

(I'm the author of WinSCP)

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Could you perhaps include some code that details how to do the replacement here? You can still include the links, of course; but the answer should contain the pertinent information. (I love WinSCP, by the way!) – Andrew Barber Jun 02 '14 at 21:40
  • I've included details on the conversion. – Martin Prikryl Jun 03 '14 at 06:34