使用脚本在 FileZilla 中自动上传文件

use*_*071 5 script upload filezilla

考虑:

D:\Program Files\FileZilla FTP Client\filezilla.exe -c 0/GG/DG/ -a "K:\YY\XXXXX\AAAA\BB\idS.txt"
Run Code Online (Sandbox Code Playgroud)

此代码不起作用,因为它说:

“找不到路径” K:\YY\XXXXX\AAAA\BB\idS.txt

然而

D:\Program Files\FileZilla FTP Client\filezilla.exe -c 0/GG/DG/ -a "K:\YY\XXXXX\AAAA\BB"
Run Code Online (Sandbox Code Playgroud)

只需连接到我希望的 FTP 站点,无需传输任何文件。

为什么它不起作用?

Mar*_*ryl 15

FileZilla 没有任何允许自动传输的命令行参数(也没有任何其他方式)。请参阅:
FileZilla 客户端命令行参数
https://trac.filezilla-project.org/ticket/2317
如何从命令行使用 FileZilla 发送文件?


尽管您可以使用任何其他允许自动化的客户端。您尚未指定您使用的协议是 FTP 还是 SFTP。

您一定可以使用 WinSCP,因为它支持 FileZilla 执行的所有协议(以及更多协议)。

请参阅https://winscp.net/eng/docs/guide_automation

用于上传的典型 WinSCP 脚本如下所示:

open sftp://user:password@example.com/ -hostkey="ssh-rsa 2048 xxxxxxxxxxx...="
put c:\mypdfs\*.pdf /home/user/
exit
Run Code Online (Sandbox Code Playgroud)

要运行脚本,请使用:

WinSCP.com /log=ftp.log /script=script.txt
Run Code Online (Sandbox Code Playgroud)

这是用于 SFTP。如果您使用的是 FTP,只需将 替换sftp://ftp://并删除-hostkey=...


WinSCP 可以从导入的 FileZilla 会话生成脚本

有关详细信息,请参阅FileZilla 自动化指南

(我是 WinSCP 的作者)


如果您使用 SFTP,另一个选择是 psftp 客户端:https ://the.earth.li/~sgtatham/putty/latest/htmldoc/Chapter6.html#psftp


Ƭᴇc*_*007 0

-a告诉 FileZilla 客户端应该在哪里完成本地文件工作。也就是说,默认情况下应将文件下载或上传到此处(如果传输命令本身未使用特定路径)。

它需要一个文件夹的路径。

来自FileZilla 文档

-a,--本地=

将本地站点(左侧)设置为给定路径。

对其中包含空格的路径使用双引号。

FileZilla 并不打算编写脚本(他们的目标是成为 GUI 客户端),因此无法指定要从命令行传输的文件。

也许考虑使用 Windows 内置的FTP.exe脚本编写。

ftp /?

Transfers files to and from a computer running an FTP server service
(sometimes called a daemon). Ftp can be used interactively.

FTP [-v] [-d] [-i] [-n] [-g] [-s:filename] [-a] [-A] [-x:sendbuffer] [-r:recvbuf
fer] [-b:asyncbuffers] [-w:windowsize] [host]

  -v              Suppresses display of remote server responses.
  -n              Suppresses auto-login upon initial connection.
  -i              Turns off interactive prompting during multiple file
                  transfers.
  -d              Enables debugging.
  -g              Disables filename globbing (see GLOB command).
  -s:filename     Specifies a text file containing FTP commands; the
                  commands will automatically run after FTP starts.
  -a              Use any local interface when binding data connection.
  -A              login as anonymous.
  -x:send sockbuf Overrides the default SO_SNDBUF size of 8192.
  -r:recv sockbuf Overrides the default SO_RCVBUF size of 8192.
  -b:async count  Overrides the default async count of 3
  -w:windowsize   Overrides the default transfer buffer size of 65535.
  host            Specifies the host name or IP address of the remote
                  host to connect to.

Notes:
  - mget and mput commands take y/n/q for yes/no/quit.
  - Use Control-C to abort commands.
Run Code Online (Sandbox Code Playgroud)