我正在尝试在python 2.7中创建基于终端的ftp客户端。 我设置了一个服务器(FileZilla Server版本0.9.41 beta),并尝试执行与该服务器通信的脚本。
我的Client.py:
import socket
import time
host = raw_input("ip ->")
port = 21
s = socket.socket()
s.connect((host, port))
print s.recv(8192)
print s.recv(8192)
s.send("USER user")
print "sent"
print s.recv(512)
s.close()
Client.py输出:
ip ->localhost
220-FileZilla Server version 0.9.41 beta
220-written by Tim Kosse (Tim.Kosse@gmx.de)
220 Please visit http://sourceforge.net/projects/file
sent
421 Login time exceeded. Closing control connection.
服务器输出:
(000010)02.01.2017 03:45:22 - (not logged in) (127.0.0.1)> Connected, sending welcome message...
(000010)02.01.2017 03:45:22 - (not logged in) (127.0.0.1)> 220-FileZilla Server version 0.9.41 beta
(000010)02.01.2017 03:45:22 - (not logged in) (127.0.0.1)> 220-written by Tim Kosse (Tim.Kosse@gmx.de)
(000010)02.01.2017 03:45:22 - (not logged in) (127.0.0.1)> 220 Please visit http://sourceforge.net/projects/filezilla/
(000010)02.01.2017 03:46:22 - (not logged in) (127.0.0.1)> 421 Login time exceeded. Closing control connection.
(000010)02.01.2017 03:46:22 - (not logged in) (127.0.0.1)> disconnected.
为什么服务器会忽略我的“USER用户”请求? (我想在没有其他图书馆/模块的帮助下编写代码而不是“socket”,(我知道ftplib的存在,但我不想使用它))))
答案 0 :(得分:1)
尝试在\r\n
之后添加USER user
。