使用FTP将文件上传到多个文件夹
答
下面是我通过docs会后想出了一个教程:
- 下载并安装WinSCP并运行它
- 连接到服务器
- 转到菜单>会话>服务器/协议信息
- 复制 “Server host key指纹”(
ssh-rsa 2048 xx:xx:xx:xx..."
)
现在创建一个名为upload.txt
文件,添加以下内容(根据需要修改):
# Connect
open sftp://user:[email protected]/ -hostkey="ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx..."
# Change remote directory
cd /home/user/public
# Download file to the local directory d:
get robots.txt d:\
# Upload file to current working directory
put d:\examplefile.txt
# Disconnect
close
# Exit WinSCP
exit
接下来创建一个批处理文件run.bat
用正确的路径:
"C:\Program Files (x86)\WinSCP\WinSCP.com" /ini=nul /script="C:\folder-with-uploadfile\upload.txt"
pause
运行该批处理文件。
检查检查文件robots.txt是否已下载到文件夹D:并且examplefile.txt位于服务器上的示例文件夹中。
在多台服务器的情况下:https://winscp.net/eng/docs/script_upload_multiple_servers
PS:我的FileZilla的长期用户,但2018年2月,他们没有这个功能呢。所以为WinSCP +1。
+1虽然您最好使用'winscp.com'而不是'winscp.exe',以便您可以在控制台窗口中看到进度(和错误)。 – 2018-02-15 07:45:36
伟大的提示。发布更新。并且:您创建的令人敬畏的软件。脚本将节省数小时的时间。 – 2018-02-15 07:53:30