在 Python 中使用 ftplib 进行 FTP 代理



我正在尝试使用来自Python的ftp代理,使用ftplib模块连接到ftp站点。

当我从命令行手动执行此操作时,它可以工作:

$ ftp ftpproxy.services
Connected to ftpproxy.services 
Name (ftpproxy.services:myaccount): myuser
230- user myuser logged in.
230 [002-0024] Specify Remote Destination with: quote site hostname
Remote system type is UNIX.
ftp> quote site mysite.com
220-(    [002-0059] Firewall connected to mysite.com (192.x.x.x).)
220-(220 ProFTPD 1.3.4d Server ready.)
220 [002-0060] login with: user name

当使用Python 3.5或Python 2.7.5时,它似乎不接受我的"引用站点 mysite.com"命令:

>>> ftp = FTP( 'ftpproxy.services', user='myuser' )
>>> ftp.set_debuglevel(1)
>>> ftp.sendcmd("quote site mysite.com")
*cmd* 'quote site mysite.com'
*resp* '200 [002-0046] Specify Remote Destination with: quote site hostname'
'200 [002-0046] Specify Remote Destination with: quote site hostname'

其他人过去似乎对此没有问题,请参阅链接

多亏了这一点,我才想通了。

使用

ftplib 时,您不应该在"引用站点 mysite.com"中使用"quote",因此与其使用 ftp.sendcmd("quote site mysite.com"),只需使用 ftp.sendcmd("site mysite.com") 即可

最新更新