IV.B FTP 应答
服务器针对用户的 FTP 命令,经由 TELNET 连接发送 FTP 应答。FTP 应答构成确认或完成码(包括错误)。FTP 服务器的应答格式既便于人阅读,也便于程序解释。单行应答由开头的三位数字码、一个空格和对该代码的一行文字说明组成。对于包含多行文本的应答,第一行以三位数字码开头,紧跟 ASCII 字符“-”(连字符,代码 55(八进制)),后面可能带有一些文本。除最后一行外,所有后续的续行都不得以三位数字开头;最后一行必须重复第一行的数字码,并紧跟一个空格。
例如:
100-First Line
Continuation Line
Another Line
100 Last Line
数字码按组分配,其方式便于程序解释,并与 RJE 协议等其他协议保持一致。代码的三位数字解释如下:
a) 第一位数字指定响应的类型,如下所示:
000 These replies are purely informative and constitute neither a
positive nor a negative acknowledgment.
1xx Informative replies to status inquiries. These constitute a
positive acknowledgment to the status command.
2xx Positive acknowledgment of previous command or other success-
ful action.
3xx Incomplete information. Activity cannot proceed without
further specification and input.
4xx Unsuccessful reply. The request is correctly specified but
the server is unsuccessful in correctly fulfilling it.
5xx Incorrect or illegal command. The command or its parameters
were invalid or incomplete from a syntactic viewpoint, or the
command is inconsistent with a previous command. The command
in question has been completely ignored.
6xx-9xx Reserved for future expansion.
即:000 为纯信息性应答,既非肯定也非否定的确认;1xx 为对状态查询的信息性应答,构成对状态命令的肯定确认;2xx 为对先前命令或其他成功动作的肯定确认;3xx 表示信息不完整,没有进一步的说明和输入,活动无法继续;4xx 为不成功的应答,请求的说明正确,但服务器未能正确完成;5xx 为不正确或非法的命令,命令或其参数在语法上无效或不完整,或命令与先前的命令不一致,所涉命令已被完全忽略;6xx-9xx 保留以备将来扩展。
b) 第二位数字指定应答所涉及的一般类别:
x00-x29 General purpose replies, not assignable to other
categories.
x30 Primary access. Informative replies to the "log-on" attempt.
x40 Secondary access. The primary server is commenting on its
ability to access a secondary service.
x5x FTP results
x6x RJE results.
x7x-x9x Reserved for future expansion.
即:x00-x29 为通用应答,无法归入其他类别;x30 为主访问,对“登录”尝试的信息性应答;x40 为次级访问,主服务器就其访问次级服务的能力所作的说明;x5x 为 FTP 结果;x6x 为 RJE 结果;x7x-x9x 保留以备将来扩展。
c) 最后一位数字指定具体的消息类型。由于代码是供自动化进程解释的,因此并不需要为应答的每一种变体都分配唯一的编号。只有应答的基本含义才需要唯一编号。应答的文本可以向人类用户说明该应答的具体原因。
由服务器发送的、以数字码和 CRLF 分隔的每一条 TELNET 行(或由带代码的行界定的一组文本行),都应是一条完整的应答消息。需要注意,应答的文本是供人类用户阅读的。只有应答码,以及在某些情况下的第一行文本,是供程序使用的。
已分配的与 FTP 相关的应答码如下:
000 General information message (site, time of day, etc.).
010 Message from system operator.
030 Server availability information.
050 FTP commentary or user information.
100 System status reply.
110 System busy doing...
150 File status reply
151 Directory listing reply.
200 Last command received correctly.
201 An ABORT has terminated activity, as requested.
202 Abort request ignored, no activity in progress.
230 User is "logged in". May proceed.
231 User is "logged out". Service terminated.
232 Logout command noted, will complete when transfer done.
233 User is "logged out". Parameters reinitialized.
250 FTP file transfer started correctly.
251 FTP Restart-marker reply.
Text is : MARK yyyy = mmmm
where yyyy is user's data stream marker (yours)
and mmmm is server's equivalent marker (mine)
(Note the spaces between the markers and '=')
252 FTP transfer completed correctly.
253 Rename completed.
254 Delete completed.
255 FTP server data socket reply
Text is: SOCK nnnn
where nnnn is a decimal integer representing
the server socket for data connection
256 Mail completed.
300 Connection greeting message, awaiting input.
301 Current command incompleted (no CRLF for long time).
330 Enter password
331 Enter account (if account required as part of login
sequence).
350 Enter mail, terminate by a line with only a '.'
400 This service not implemented.
401 This service not accepting user now, goodbye.
430 Log-on time or tries exceeded, goodbye.
431 Log-on unsuccessful. Usre and/or password invalid.
432 User not valid for this service.
433 Cannot transfer files without valid account. Enter account.
434 Log-out forced by operator action. Phone site.
435 Log-out forced by system problem.
436 Service shutting down, goodbye.
450 FTP: File not found.
451 FTP: File access denied to you.
452 FTP: File transfer incomplete, data connection closed.
453 FTP: File transfer incomplete, insufficient storage space.
454 FTP: Cannot connect to your data socket.
455 FTP: File system error not covered by other reply codes.
456 FTP: Name duplication rename failed.
457 FTP: Transfer parameters in error.
500 Last command line completely unrecognized.
501 Syntax of last command is incorrect.
502 Last command incomplete, parameters missing.
123456789012345678901234567890123456789012345678901234567890123456789012
503 Last command invalid (ignored), illegal parameter combination.
504 Last command invalid, action not possible at this time.
505 Last command conflicts illegally with previous command(s).
506 Requested action not implemented by the server.
507 Catchall error reply.
550 Bad pathname specification (e.g., syntax error).