使用Python中的ftplib进行FTP代理

时间:2017-05-08 21:51:29

标签: python ftplib

我正在尝试使用ftplib模块使用Python的ftp代理连接到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'

其他人似乎过去没有遇到任何问题,请参阅link

1 个答案:

答案 0 :(得分:1)

感谢this我已经弄明白了。

使用ftplib时,不应使用“引用网站mysite.com”中的“引用”,因此请使用id code 4 | G 4 | O 5 | I 3 | G 3 | I 8 | G 8 | I 8 | O 9 | G 代替ftp.sendcmd("quote site mysite.com"),然后才能使用。