FTP File Transfer Protocol 033 (some commands)

Source: Internet
Author: User
Tags ftp commands ftp file printable characters terminates file transfer protocol ftp file transfer ftp file transfer protocol

4. File Transfer

The channel from the user pi to the server is established between the user and the server port. The user protocol interpreter is responsible for sending commands and interpreting received responses. The server PI interprets commands and sends responses to instruct DTP to establish data connections and transmit data. If the second side of data transmission is user DTP, control it through the internal protocol of the user FTP host; if the second side is server DTP, it is controlled by the user PI commands through its own PI.

4.1. FTP command

4.1.1. Access Control commands

The following command specifies the access control flag (the authorization code is in brackets ):

User)

The parameter indicates the user's telnet string. User tags are required to access the server. This command is usually the first command issued after the connection is controlled. Some hosts also require passwords and accounts. The server can receive new user commands at any time to change access control and (or) account information. This allows you to re-start the logon process, so the transmission parameters remain unchanged. The ongoing file transmission is completed under the previous access control parameters.

Password (PASS)

The parameter is a telnet string that marks the user password. This command follows the USER command, which is an indispensable step for access control on some sites. Therefore, passwords are important and cannot be displayed. The server cannot hide the passwords. Therefore, this task must be completed by the user's FTP process.

Account (ACCT)

The parameter is the Telnet string that marks the user account. This command does not need to be related to users. Some sites may need accounts for logon, while others can restrict account permissions. In the latter case, this command can be sent at any time. Different responses can be different: When the logon requires account information, the response to the PASS Command is 332. In addition, if you do not need account information, the response to pass is 230. If you need account information later, the server will return 332 or 532, it depends on whether the command is saved or rejected.

Change working directory (CWD)

This command allows users to work in different directories or datasets without changing their logon or account information. The transmission parameters remain unchanged. A parameter is generally a directory name or a collection of system-related files.

Return to the previous directory (cdup)

This command requires the system to implement the directory tree structure, and its response is the same as that of CWD.

Structure loading (SMNT)

This command enables the user to load the data structure of another file system without changing the login or account information. The transmission parameters remain unchanged. A parameter is a file directory or a collection of system-related files.

Rein)

This command terminates the user and writes all I/O and account information, but the ongoing data transmission is not allowed to complete. Reset all parameters to control the connection opening. You can start the USER command again.

Log out (quit)

This command terminates the user. If there is no data transmission, the server closes the control connection. If there is data transmission, the server closes the control connection after receiving the transmission response. If the user process is transmitting data to different users and you do not want to disable and enable each user, you can use rein. The accidental shutdown of the control connection can cause the server to stop (Abor) and log out (quit ).

4.1.2. transmission parameter command

All data transmission parameters have default values. The server must record the default value, which can be sent in any order after FTP service requests. The following command transfers parameters:

Data port)

The parameter is the data connection port to be used. Generally, no command response is required. If you use this command, you need to send a 32-bit IP address and a 16-bit TCP port number. The above information is transmitted in decimal format with a comma (,), as shown in the following example:

Port H1, H2, H3, H4, p1, p2

H1 is the maximum 8-bit IP address.

Passive (PASV)

This command requires the server DTP to listen on the specified data port and enter the passive request receiving status. The parameter is the host and port address.

Type)

The parameter specifies the type. For some types, the second parameter is required. The first parameter is defined by a single Telnet character. The second parameter is a decimal integer that specifies the byte size. The parameters are separated by <SP>. The format is as follows:

The default type is ASCII non-printable characters. If the parameter is not changed and only the first parameter is changed later, the default value is used.

File structure (stru)

The parameter is a telnet character.CodeSpecify the file structure. The following is the code and its meaning:

F-file (non-record structure), which is the default value

R-record Structure

P-Page Structure

Transmission Mode)

The parameter is a telnet character code that specifies the transmission mode. The following is the code and its meaning:

S-stream (default)

B-block

C-compression

4.1.3. FTP service commands

The FTP service command defines the file transfer or file system functions requested by the user. The parameter of this command is usually the path name, and its syntax must be consistent with the specifications of the server. The Recommended default value is the recently specified Device directory or directory. There is usually no limit on the command order. Only the "RENAME from" command must be followed by "RENAME to", and the restart command must be followed by the interrupt service command. Responses to service commands are usually transmitted over data connections. The following is a specific command:

Get file (RETR)

This command allows the server DTP to send a copy of the file in the specified path to the server or user DTP. The status and content of files on the server are not affected.

Save (stor)

This command allows the server DTP to receive the data transmitted over the data connection and save the data in the Server File. If the file already exists, the original file will be overwritten. If the file does not exist, create a new file.

Unique storage (STOU)

This command is similar to stor. The file name in this directory must be unique. The response to this command must include the generated user name.

Additional (APPE)

It is similar to the stor function, but if the file already exists in the specified path, the data is appended to the end of the original file. If the file does not exist, the new file is created.

Allocation (allo)

This command is used to allocate sufficient storage space for newly transferred files on some hosts. The parameter is the number of logical bytes in decimal format. For a record or page structure, the maximum page or record size is also required, which is specified in decimal in the second parameter. The second parameter is optional. If it exists, it is separated from the first parameter by the Telnet character <SP> r <SP>. After the STOR or APPE Command, this command serves as Noop for machines that do not need to allocate storage space.

Start again (rest)

The parameter field indicates the point where the server needs to start again. This command does not transfer files, but skips the data after the specified point. After this command, it should be followed by other FTP commands that require file transmission.

Rename (RNFR)

This command is the same as what we use in other operating systems, except that the new file name must be specified with "RENAME.

Rename it to (RNTO)

This command is used together with the preceding command to rename the file.

Abandon (Abor)

This command notifies the service to abort the previous FTP command and related data transfer. If the previous operation has been completed, no action is returned, and 226 is returned. If not, 426 is returned and 226 is returned. Close the control connection. The data connection is not closed.

Delete (DELE)

This command deletes objects in the specified path. The user process is responsible for the deletion prompt.

Delete directory (RMD)

This command deletes the directory.

Create directory (MKD)

This command creates a new directory in the specified path.

Print the working directory (PWD)

In the response, the current working directory is returned.

List)

The server transfers the list to passive DTP. If a directory or multiple files are specified in the path, the list of files in the specified path is returned. If the path name specifies a file, the server returns the current information of the file. If the parameter is null, it indicates the current working directory or default directory of the user. Data is transmitted in ASCII or ebcdic. You must confirm this. Because the file information varies by systemProgramAutomatic exploitation, but human users need it.

Name List (NLST)

The server transfers the directory table name to the user. The path name should specify the directory or the file group description specified by other systems. The null parameter indicates the current directory. The file name data stream returned by the server is transmitted in ASCII or ebcdic format and separated by <CRLF> or <NL>. The returned information can be further processed by the program.

Site Parameters)

The server is used to provide the server system information. The information varies with the system. The format is provided in the help site command response.

System (syst)

Used to determine the operating system running on the server.

Status (STAT)

This command returns the control connection status, which can be sent during file transfer and the server returns the status of the operation. It can also be sent between file transfers. At this time, the command has a parameter, and the parameter is the path name. The function of this command is similar to that of the LIST command in addition to data transfer over the control connection. If a part of the path is specified, the server returns a file name or description-related attribute. If no parameter exists, the server returns the status information of the FTP process on the server, including the current value and connection status of the transmission parameter.

Help)

There is no difference in the help of this command in common systems. The response type is 211 or 214. We recommend that you use this command before using the USER command.

Wait (Noop)

This command does not generate any actual action. It only causes the server to Return OK.

FTP uses Telnet for communication over the control connection, so you have the opportunity to read the relevant protocol description. The following sections will be helpful. The following describes the command response and detailed information about the command. FTP commands can be divided into access control tags, data transmission parameters or FTP service requests. Specific commands (such as Abor and STAT) can be transmitted over control connections during data transmission. Some servers cannot monitor data and control links at the same time, so they must take other measures. Pay attention to the following suggestions:

1. the user system inserts the "interrupt process" (IP) Information of telnet into the Telnet stream;

2. the user system sends the "synch" signal for telnet;

3. the user system inserts commands (such as Abor) into the Telnet stream;

4. After receiving the IP address, the server PI finds only one FTP command in the Telnet stream.

4.2. FTP Response

The FTP command response is to synchronize data transmission requests and processes, and also to let users know the server status. Each Command must have at least one response. If there are multiple responses, they must be easy to differentiate. Some commands are ordered. Therefore, failure of any of these commands may lead to a start from scratch. The FTP Response consists of three numbers followed by some text. The number carries enough information to name the user pi. You do not need to check the text to know what is going on. The text information is related to the server. Users may obtain different text information. The text and numbers are separated by <SP>, and the text ends with a telnet line terminator. There may be more than one line of text. In this case, the text must be enclosed in brackets. The information in the first line indicates that there are more than one line of text, and the last line must be marked. If there are multiple lines, you can add "-" after the number code, the last line starts with a number, followed by <SP>, and the line terminator of Telnet. The following is an example:

123-first line

Row 2

234 a row starting with a number

123 last line

Each of the three digits has a certain significance. The first digit determines whether the response is good or not. By checking the first digit, the user process can usually know what action to take. If the user program wants to know what is wrong, you can check the second digit, and leave the third digit to indicate other information. The first digit has five values:

1yz confirm the prepared response

The requested operation is being initialized; wait for another response before entering the next command. This type of response is used to explain whether the command is accepted and how to monitor it synchronously is difficult during implementation. The user process can now focus on data connections. The FTP process on the server returns a 1yz response to almost all the first commands.

2yz confirm to complete the response

The required operation has been completed. You can execute a new command.

3yz determines the intermediate response

The command is accepted, but the required operation is stopped. Stop receiving updated information.

4yz temporarily refused to complete the response

If the command is not accepted, the required operation is not executed, but the error is temporary. You can send the message again later. The user should return the start of the command sequence. This command is temporarily uncertain. It means that the user process will try to use this command again.

5yz always refuses to complete the response

The difference between it and the temporary refusal to complete the response is that the error condition is that half past one will not disappear.

Next let's take a look at the meaning of the second digit:

X0z format error;

X1z this type of response is for request information;

X2z is related to control and data connection;

X3z about the authentication and account logon process;

X4z not used;

X5z is related to the file system;

The third digit is a further refinement of the response content based on the second digit. Generally, text information is required after the numeric code. Use existing code whenever possible, instead of adding new code with little significance.

Some commands, such as type or allo, do not provide new task information for the user process, so no 200 response is returned. If some commands are not supported by the server, you need to return a confirmation to complete the response, so that the user process can perform the following commands. If the required command is not an optional implementation command, but this command is indeed not implemented, it will return code 502. Next we will list each response code in numerical order and its significance:

110

Restart to mark the response. In this case, the text is determined. It must be Mark yyyy = Mmmm, where yyyy is the user process data stream mark and mmmm is the server mark.

120

Service ready in NNN minutes

125

Data Connection enabled, ready for transfer

150

The file is in good state and data connection is enabled.

200

Command successful

202

Command not implemented

211

System status or system help response

212

Directory status

213

File status

214

Help information, which is only useful to human users

215

Name System Type

220

Prepare services for new users

221

The service closes the control connection and can log out.

225

Data Connection is enabled, no transmission is in progress

226

The data connection is closed and the requested file operation is successful.

227

Enter passive mode

230

User Logon

250

Requested file operation completed

257

Create "pathname"

331

The user name is correct. A password is required.

332

Account Information Required for Logon

350

The requested file operation requires further commands

421

Cannot provide services. Close the control connection

425

Cannot open data connection

426

Disconnect and stop transmission

450

Requested file operation not executed

451

Abort request operation: there is a local error

452

Unrequested operation: insufficient system storage space

500

Format error. The command is not recognizable

501

Parameter syntax error

502

Command not implemented

503

Command Order Error

504

The command function under this parameter is not implemented

530

Not logged on

532

Account information required to store files

550

Requested operation not performed

551

Request operation aborted: Unknown page type

552

The requested file operation is aborted, and the storage allocation overflows.

553

Action not requested: invalid file name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.