Windows Command Line FTP to deploy website

2019-06-10 06:32发布

问题:

Trying to set up a post build script on my CI server to push changes to our web server by FTP. In as few lines as possible how can i push a folder of files to my webserver using windows FTP? For example deployment folder is:

c:\deployment\*.*

How can i recursively push all files to replace on the web server?

I'm open to using cmd or powershell - MS Windows only

Thanks

回答1:

Windows' built-in command-line FTP client doesn't have recursion built-in. The easiest way would be to use a different FTP client. NcFTP will do what you're looking for. See the manual page for ncftpput. The syntax is basically as follows:

cd c:\deployment
ncftpput -u user -p pass -R ftp.ftpserver.com /path/on/ftp/server .\*

Or if your web server also runs an ssh service, then rsync would be even better.



回答2:

Fsync is good, I am using it for long. It allows to push only what has changed. Recursion of course. Exclude files, too. Track client-side (much faster) what has changed... Biggest only drawback: No SFTP./ProductList/Fsync.html