📄 ftp.txt
字号:
APPEND (with create) (APPE) This command causes the server-DTP to accept the data transferred via the data connection and to store the data in a file at the server site. If the file specified in the pathname exists at the server site, then the data shall be appended to that file; otherwise the file specified in the pathname shall be created at the server site. ALLOCATE (ALLO) This command may be required by some servers to reserve sufficient storage to accommodate the new file to be transferred. The argument shall be a decimal integer representing the number of bytes (using the logical byte size) of storage to be reserved for the file. For files sent with record or page structure a maximum record or page size (in logical bytes) might also be necessary; this is indicated by a decimal integer in a second argument field ofPostel & Reynolds [Page 30] RFC 959 October 1985File Transfer Protocol the command. This second argument is optional, but when present should be separated from the first by the three Telnet characters <SP> R <SP>. This command shall be followed by a STORe or APPEnd command. The ALLO command should be treated as a NOOP (no operation) by those servers which do not require that the maximum size of the file be declared beforehand, and those servers interested in only the maximum record or page size should accept a dummy value in the first argument and ignore it. RESTART (REST) The argument field represents the server marker at which file transfer is to be restarted. This command does not cause file transfer but skips over the file to the specified data checkpoint. This command shall be immediately followed by the appropriate FTP service command which shall cause file transfer to resume. RENAME FROM (RNFR) This command specifies the old pathname of the file which is to be renamed. This command must be immediately followed by a "rename to" command specifying the new file pathname. RENAME TO (RNTO) This command specifies the new pathname of the file specified in the immediately preceding "rename from" command. Together the two commands cause a file to be renamed. ABORT (ABOR) This command tells the server to abort the previous FTP service command and any associated transfer of data. The abort command may require "special action", as discussed in the Section on FTP Commands, to force recognition by the server. No action is to be taken if the previous command has been completed (including data transfer). The control connection is not to be closed by the server, but the data connection must be closed. There are two cases for the server upon receipt of this command: (1) the FTP service command was already completed, or (2) the FTP service command is still in progress.Postel & Reynolds [Page 31] RFC 959 October 1985File Transfer Protocol In the first case, the server closes the data connection (if it is open) and responds with a 226 reply, indicating that the abort command was successfully processed. In the second case, the server aborts the FTP service in progress and closes the data connection, returning a 426 reply to indicate that the service request terminated abnormally. The server then sends a 226 reply, indicating that the abort command was successfully processed. DELETE (DELE) This command causes the file specified in the pathname to be deleted at the server site. If an extra level of protection is desired (such as the query, "Do you really wish to delete?"), it should be provided by the user-FTP process. REMOVE DIRECTORY (RMD) This command causes the directory specified in the pathname to be removed as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative). See Appendix II. MAKE DIRECTORY (MKD) This command causes the directory specified in the pathname to be created as a directory (if the pathname is absolute) or as a subdirectory of the current working directory (if the pathname is relative). See Appendix II. PRINT WORKING DIRECTORY (PWD) This command causes the name of the current working directory to be returned in the reply. See Appendix II. LIST (LIST) This command causes a list to be sent from the server to the passive DTP. If the pathname specifies a directory or other group of files, the server should transfer a list of files in the specified directory. If the pathname specifies a file then the server should send current information on the file. A null argument implies the user's current working or default directory. The data transfer is over the data connection in type ASCII or type EBCDIC. (The user mustPostel & Reynolds [Page 32] RFC 959 October 1985File Transfer Protocol ensure that the TYPE is appropriately ASCII or EBCDIC). Since the information on a file may vary widely from system to system, this information may be hard to use automatically in a program, but may be quite useful to a human user. NAME LIST (NLST) This command causes a directory listing to be sent from server to user site. The pathname should specify a directory or other system-specific file group descriptor; a null argument implies the current directory. The server will return a stream of names of files and no other information. The data will be transferred in ASCII or EBCDIC type over the data connection as valid pathname strings separated by <CRLF> or <NL>. (Again the user must ensure that the TYPE is correct.) This command is intended to return information that can be used by a program to further process the files automatically. For example, in the implementation of a "multiple get" function. SITE PARAMETERS (SITE) This command is used by the server to provide services specific to his system that are essential to file transfer but not sufficiently universal to be included as commands in the protocol. The nature of these services and the specification of their syntax can be stated in a reply to the HELP SITE command. SYSTEM (SYST) This command is used to find out the type of operating system at the server. The reply shall have as its first word one of the system names listed in the current version of the Assigned Numbers document [4]. STATUS (STAT) This command shall cause a status response to be sent over the control connection in the form of a reply. The command may be sent during a file transfer (along with the Telnet IP and Synch signals--see the Section on FTP Commands) in which case the server will respond with the status of the operation in progress, or it may be sent between file transfers. In the latter case, the command may have an argument field. If the argument is a pathname, the command is analogous to the "list" command except that data shall bePostel & Reynolds [Page 33] RFC 959 October 1985File Transfer Protocol transferred over the control connection. If a partial pathname is given, the server may respond with a list of file names or attributes associated with that specification. If no argument is given, the server should return general status information about the server FTP process. This should include current values of all transfer parameters and the status of connections. HELP (HELP) This command shall cause the server to send helpful information regarding its implementation status over the control connection to the user. The command may take an argument (e.g., any command name) and return more specific information as a response. The reply is type 211 or 214. It is suggested that HELP be allowed before entering a USER command. The server may use this reply to specify site-dependent parameters, e.g., in response to HELP SITE. NOOP (NOOP) This command does not affect any parameters or previously entered commands. It specifies no action other than that the server send an OK reply.
关于FTP的断点续传
作者: ppnote 发表日期: 2006-10-22 23:38 文章属性: 原创 复制链接
断点续传的功能实现其实就是把服务器上的文件和本地的文件作一个文件指针的同步,然后通知开始下载或者上传。
FTP的上传和下载是在2个通道分别是命令通道和数据通道中进行。在编程中要注意到这一点。这个当时我就走了弯路,
没注意到,呵呵。
具体的实现是:
1)上传,要用到下面的命令
USER
PASS
TYPE I
CWD
PASV
SIZE
REST
STOR
首先用SIZE获得服务器上文件的大小,然后发送REST通知服务器定位到某个文件的读写点,在本地的文件也要手动定
位到该文件的读写点,发送STOR开始传送数据。
2)下载,要用到
USER
PASS
TYPE I
CWD
PASV
SIZE
REST
RETR
首先用api获得本地文件的大小,然后发送REST通知服务器定位到某个文件的读写点,在本地的文件也要手动定位到该
文件的读写点,发送RETR开始接收数据。
具体的命令要查FTP协议:rfc959。
----------------------------------------------------------------------------------------
附录:
命令 描述
ABOR 中断数据连接程序
ACCT account> 系统特权帐号
ALLO bytes> 为服务器上的文件存储器分配字节
APPE filename> 添加文件到服务器同名文件
CDUP dir path> 改变服务器上的父目录
CWD dir path> 改变服务器上的工作目录
DELE filename> 删除服务器上的指定文件
HELP command> 返回指定命令信息
LIST name> 如果是文件名列出文件信息,如果是目录则列出文件列表
MODE mode> 传输模式(S=流模式,B=块模式,C=压缩模式)
MKD directory> 在服务器上建立指定目录
NLST directory> 列出指定目录内容
NOOP 无动作,除了来自服务器上的承认
PASS password> 系统登录密码
PASV 请求服务器等待数据连接
PORT address> IP 地址和两字节的端口 ID
PWD 显示当前工作目录
QUIT 从 FTP 服务器上退出登录
REIN 重新初始化登录状态连接
REST offset> 由特定偏移量重启文件传递
RETR filename> 从服务器上找回(复制)文件
RMD directory> 在服务器上删除指定目录
RNFR old path> 对旧路径重命名
RNTO new path> 对新路径重命名
SITE params> 由服务器提供的站点特殊参数
SMNT pathname> 挂载指定文件结构
STAT directory> 在当前程序或目录上返回信息
STOR filename> 储存(复制)文件到服务器上
STOU filename> 储存文件到服务器名称上
STRU type> 数据结构(F=文件,R=记录,P=页面)
SYST 返回服务器使用的操作系统
TYPE data type> 数据类型(A=ASCII,E=EBCDIC,I=binary)
USER username>> 系统登录的用户名
标准 FTP 信息如下:
响应代码 解释说明
110 新文件指示器上的重启标记
120 服务器准备就绪的时间(分钟数)
125 打开数据连接,开始传输
150 打开连接
200 成功
202 命令没有执行
211 系统状态回复
212 目录状态回复
213 文件状态回复
214 帮助信息回复
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -