FTP协议命令+返回值+返回值解析
FTP message format:
FTP commands are Telnet strings terminated by the Telnet end of line code. The command codes themselves are alphabetic character strings terminated by the character <Space> if parameters follow and <CRLF> otherwise.
FTP Commands:
命令 描述 响应码
_________________________________________________________________________________________________________________
ABOR Abort.
中断数据连接程序
_________________________________________________________________________________________________________________
ACCT Account. 202,230,421,500,501,502,503,530
系统特权账号
_________________________________________________________________________________________________________________
ADAT Authentication/Security Data.
_________________________________________________________________________________________________________________
ALLO Allocate.
为服务器上的文件存储器分配字节
_________________________________________________________________________________________________________________
APPE Append.
添加文件到服务器同名文件
_________________________________________________________________________________________________________________
AUTH Authentication/Security Mechanism.
_________________________________________________________________________________________________________________
CCC Clear Command Channel.
_________________________________________________________________________________________________________________
CDUP Change to parent directory. 250,421,500,502,530,550
改变服务器上的父目录
_________________________________________________________________________________________________________________
CONF Confidentiality Protected Command.
_________________________________________________________________________________________________________________
CWD Change working directory. 250,421,500,501,502,530,550
改变服务器上的工作目录
_________________________________________________________________________________________________________________
DELE Delete. 250,421,502,530,550
删除服务器上的指定文件
_________________________________________________________________________________________________________________
ENC Privacy Protected Command.
_________________________________________________________________________________________________________________
EPRT Extended Data port.
_________________________________________________________________________________________________________________
EPSV Extended Passive.
_________________________________________________________________________________________________________________
FEAT Feature.
_________________________________________________________________________________________________________________
HELP Help.
返回指定命令信息
_________________________________________________________________________________________________________________
LANG Language negotiation.
_________________________________________________________________________________________________________________
LIST List. 125,150,226,250,421,425,426,450, 451,500,501,502,530
如果是文件名列出文件信息,如果是目录则列出文件列表
_________________________________________________________________________________________________________________
LPRT Long data port.
_________________________________________________________________________________________________________________
LPSV Long passive.
_________________________________________________________________________________________________________________
MDTM File modification time.
_________________________________________________________________________________________________________________
MIC Integrity Protected Command.
_________________________________________________________________________________________________________________
MKD Make directory.
在服务器上建立指定目录
_________________________________________________________________________________________________________________
MLSD
_________________________________________________________________________________________________________________
MLST 列出指定目录内容 同LIST命令
_________________________________________________________________________________________________________________
MODE Transfer mode.
传输模式(S=流模式,B=块模式,C=压缩模式)
_________________________________________________________________________________________________________________
NLST Name list.
_________________________________________________________________________________________________________________
NOOP No operation. 200,421,500
无动作,除了来自服务器上的承认
_________________________________________________________________________________________________________________
OPTS Options.
_________________________________________________________________________________________________________________
PASS Password. 202,230,332,421,500,501,530
系统登录密码
_________________________________________________________________________________________________________________
PASV Passive mode. 227,421,500,501,503
请求服务器等待数据连接
_________________________________________________________________________________________________________________
PBSZ Protection Buffer Size.
_________________________________________________________________________________________________________________
PORT Data port. 200,421,500,501,530
IP 地址和两字节的端口 ID
_________________________________________________________________________________________________________________
PROT Data Channel Protection Level.
_________________________________________________________________________________________________________________
PWD Print working directory. 257,421,500,501,502,550
显示(打印)当前工作目录
_________________________________________________________________________________________________________________
QUIT Logout.
从 FTP 服务器上退出登录
_________________________________________________________________________________________________________________
REIN Reinitialize. 120,220,421,500,502
重新初始化登录状态连接
_________________________________________________________________________________________________________________
REST Restart of interrupted transfer. 350,421,500,501,502,530
由特定偏移量重启文件传递
_________________________________________________________________________________________________________________
RETR Retrieve. 110,125,150,226,250,421,425,426, 450,451,500,501,504,530,550
从服务器上找回(复制)文件
_________________________________________________________________________________________________________________
RMD Remove directory.
在服务器上删除指定目录
_________________________________________________________________________________________________________________
RNFR Rename from.
对旧路径重命名
_________________________________________________________________________________________________________________
RNTO Rename to.
对新路径重命名
_________________________________________________________________________________________________________________
SITE Site parameters.
由服务器提供的站点特殊参数
_________________________________________________________________________________________________________________
SIZE File size.
_________________________________________________________________________________________________________________
SMNT Structure mount.
挂载指定文件结构
_________________________________________________________________________________________________________________
STAT Status. 211,212,213,421,450,500,501,502,530
在当前程序或目录上返回信息
_________________________________________________________________________________________________________________
STOR Store. 110,125,150,226,250,421,425,426,450,451,452,500,501,504,530,532,550,551,552,553
储存(复制)文件到服务器上
_________________________________________________________________________________________________________________
STOU Store unique.
储存文件到服务器名称上
_________________________________________________________________________________________________________________
STRU File structure.
数据结构(F=文件,R=记录,P=页面)
_________________________________________________________________________________________________________________
SYST System.
返回服务器使用的操作系统
_________________________________________________________________________________________________________________
TYPE Representation type. 200,421,500,501,504,530
数据类型(A=ASCII,E=EBCDIC,I=binary)
_________________________________________________________________________________________________________________
USER User name. 230,331,332,421,500,501,530
系统登录的用户名
_________________________________________________________________________________________________________________
XCUP Change to the parent of the current working directory.
_________________________________________________________________________________________________________________
XMKD Make a directory.
_________________________________________________________________________________________________________________
XPWD Print the current working directory.
_________________________________________________________________________________________________________________
XRCP
_________________________________________________________________________________________________________________
XRMD Remove the directory.
_________________________________________________________________________________________________________________
XRSQ
_________________________________________________________________________________________________________________
XSEM Send, Mail if cannot.
_________________________________________________________________________________________________________________
XSEN Send to terminal.
_________________________________________________________________________________________________________________
FTP服务器的响应是3位的响应码,其中第一位表示响应是好、是坏还是未完:
Code Description
_________________________________________________________________________________________________________________
1yz Positive Preliminary reply.
肯定的初步答复:这些状态代码指示一项操作已经成功开始,但客户端希望在继续操作新命令前得到另一个答复。
_________________________________________________________________________________________________________________
2yz Positive Completion reply.
肯定的完成答复:一项操作已经成功完成。客户端可以执行新命令。
_________________________________________________________________________________________________________________
3yz Positive Intermediate reply.
肯定的中间答复:该命令已成功,但服务器需要更多来自客户端的信息以完成对请求的处理。
_________________________________________________________________________________________________________________
4yz Transient Negative Completion reply.
瞬态否定的完成答复:该命令不成功,但错误是暂时的。如果客户端重试命令,可能会执行成功。
_________________________________________________________________________________________________________________
5yz Permanent Negative Completion reply.
永久性否定的完成答复:该命令不成功,错误是永久性的。如果客户端重试命令,将再次出现同样的错误。
_________________________________________________________________________________________________________________
响应码第二位表示了特定的分类,具体内容如下:
Code Description
_________________________________________________________________________________________________________________
x0z Syntax. These replies refer to syntax errors, syntactically correct commands that don't fit any functional category, unimplemented or superfluous commands.
语法错误,表示不符合任何功能分类的命令,可能是未实现的命令或者多余的命令。
_________________________________________________________________________________________________________________
x1z Information. These are replies to requests for information, such as status or help.
信息类型
_________________________________________________________________________________________________________________
x2z Connections. Replies referring to the control and data connections.
连接类型
_________________________________________________________________________________________________________________
x3z Authentication and accounting. Replies for the login process and accounting procedures.
与注册或者登陆相关命令的应答
_________________________________________________________________________________________________________________
x4z 未定义
_________________________________________________________________________________________________________________
x5z File system. These replies indicate the status of the Server file system vis-a-vis the requested transfer or other file system action.
文件系统状态
_________________________________________________________________________________________________________________
响应码第三位是对第二位的分级,给出了差错的附加含义,具体内容如下:
Code Description
_________________________________________________________________________________________________________________
110 Restart marker reply. 重新启动标记答复。
120 Service ready in nnn minutes. 服务已就绪,在nnn分钟后开始。
125 Data connection already open; transfer starting. 数据连接已打开,正在开始传输。
150 File status okay; about to open data connection. 文件状态正常,准备打开数据连接。
200 Command okay. 命令确定。
202 Command not implemented, superfluous at this site. 未执行命令,站点上的命令过多
211 System status, or system help reply. 系统状态,或系统帮助答复。
212 Directory status. 目录状态。
213 File status. 文件状态。
214 Help message. 帮助消息。
215 NAME system type. NAME系统类型,其中,NAME是Assigned Numbers文档中所列的正式系统名称。
220 Service ready for new user. 服务就绪,可以执行新用户的请求。
221 Service closing control connection. 服务关闭控制连接。如果适当,请注销。
225 Data connection open; no transfer in progress. 数据连接打开,没有进行中的传输。
226 Closing data connection. 关闭数据连接。请求的文件操作已成功(例如,传输文件或放弃文件)。
227 Entering Passive Mode <h1,h2,h3,h4,p1,p2>. 进入被动模式(h1,h2,h3,h4,p1,p2)。
228 Entering Long Passive Mode.
229 Extended Passive Mode Entered.
230 User logged in, proceed. 用户已登录,继续进行。
250 Requested file action okay, completed. 请求的文件操作正确,已完成。
257 "PATHNAME" created. 已创建“PATHNAME”。
331 User name okay, need password. 用户名正确,需要密码。
332 Need account for login. 需要登录帐户。
350 Requested file action pending further information. 请求的文件操作正在等待进一步的信息。
421 Service not available, closing control connection.
服务不可用,正在关闭控制连接。如果服务确定它必须关闭,将向任何命令发送这一应答。
425 Can't open data connection. 无法打开数据连接。
426 Connection closed; transfer aborted. 连接被关闭,数据传输中断。
450 Requested file action not taken. 未执行请求的文件操作。文件不可用。
451 Requested action aborted. Local error in processing.请求的操作异常终止:正在处理本地错误。
452 Requested action not taken. 未执行请求的操作。系统存储空间不够。
500 Syntax error, command unrecognized. 语法错误,命令无法识别。这可能包括诸如命令行太长之类的错误。
501 Syntax error in parameters or arguments. 在参数中有语法错误。
502 Command not implemented. 未执行命令。
503 Bad sequence of commands. 错误的命令序列。
504 Command not implemented for that parameter. 未执行该参数的命令。
521 Supported address families are <af1, .., afn>
522 Protocol not supported.
530 Not logged in. 未登录。
532 Need account for storing files. 存储文件需要帐户。
550 Requested action not taken. 未执行请求的操作。文件不可用。
551 Requested action aborted. Page type unknown. 请求的操作异常终止:未知的页面类型。
552 Requested file action aborted. 请求的文件操作异常终止:超出存储分配(对于当前目录或数据集)。
553 Requested action not taken. 未执行请求的操作。不允许的文件名。
554 Requested action not taken: invalid REST parameter.
555 Requested action not taken: type or struct mismatch.
_________________________________________________________________________________________________________________
FTP响应通常是单行的,格式为"响应码+空格+提示信息+\r\n"。如果需要产生一条多行应答,第1行在第3位数字应答码之后包含一个连字号,而不是空格,最后一行包含相同的3位数字应答码,后跟一个空格字符。