Replace Windows command FTP -s:E:\FtpScript.txt wi

2019-06-07 04:26发布

This question already has an answer here:

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

标签: windows ftp sftp
1条回答
姐就是有狂的资本
2楼-- · 2019-06-07 05:09

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)

查看更多
登录 后发表回答