FTP Simple use command

Source: Internet
Author: User
Tags create directory ftp protocol

FTP protocol uses a series of simple protocols to complete the various tasks of file transfer, when sending commands, always at the end of the command plus a carriage return line character,

IP/TCP protocol ftp: FTP. Chapters do not look, nonsense a lot of, directly search the principle of FTP.

FTP command set English: http://www.nsftools.com/tips/RawFTP.htm.

reprint : http://blog.csdn.net/weiyuefei/article/details/51758288 Weiyuefei

Http://www.cnblogs.com/adolphyang/p/5280255.html Adolphyang

such as downloading files: You may use the function command: USER pass PASV CWD SIZE RETR

Both Windows and Linux can configure FTP capabilities. FTP software, tools, service side. Clients, everything. Source code, GitHub on the quality is relatively good.

Third-party testing using tool Ftpserver.exe.


1. Pass (Password, password) command

Description: Sends the user's password to the remote system, which is used after the user command.

Usage:pass<password><crlf>

Parameter: password is the registered user password specified by the user command.

Example:

SendData "Pass MyPassword" + "/r/n

Note: On port 21 that connects to an FTP server and receives a line that starts with code 220, the server is ready for you to send user and pass commands to the FTP server, immediately following the user command.

The pass command should follow the user command.

If you have an account number on this FTP server, you can specify your username and password. If you want to log on anonymously, you can specify the user name "Anonymous" and use your own e-mail address as the password.

The return value is as follows (bold indicates success):

The L 202 command has not been implemented and is redundant on this site.

L 230 The user is logged in, please continue.

L 332 Login requires account number (see Acct command).

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, the answer is made to all commands.

L 500 syntax error, command not recognized. This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

L 530 cannot log in.

2. PASV (passive, passive) command

Description: Tells the server to listen to a data connection on a non-standard port.

Usage:pasv<crlf>

Parameter: This command requests the SERVER-DTP (Server data Transfer Protocol) to "listen" to a data port (which is not its default data port) and wait for a connection instead of initializing a connection when the transport command is received. The response to this command includes the host address and the port address that this server is listening to.

Example:

SendData "PASV" + "/r/n

The return value is as follows (bold indicates success):

L 227 Input Passive mode (H1,H2,H3,H4,P1,P2).

The return value includes a host-port specification for the data port used in a data connection. This parameter is a 32-bit Internet host address and a concatenation of a 16-bit TCP port. This address information is split into 8-bit fields, and the value of each field is transmitted as a decimal number (in the sense of the string). H1 is the high byte of the Internet host address, p1 is the high byte of the port address.

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, the answer is made to all commands.

L 500 syntax error, command not recognized. This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

L 503 cannot log in. 3. CWD (change Working directory, changing working directory) command

Note: Change the current directory to the specified path of the remote file system without changing the login, account information, or transmission parameters.

Usage:cwd<path><crlf>

Parameter: path is a working directory on the remote system.

Example:

SendData "Cwd/pub/cgvb/uploads" + "/r/n

The return value is as follows (bold indicates success):

L 250 The requested file operation is working properly and is complete.

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, it will make this response to all life.

L 500 syntax error, command not recognized. This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

The L 502 command has not been implemented yet.

L 530 cannot log in.

L 550 The requested operation cannot be performed, the file is not available (for example, file not found, no access).

4. MKD (make directory, create directory) command

Description: Creates a directory that is specified in the path name (if it is an absolute pathname) or a subdirectory of the current working directory (if it is a relative path name).

Usage:mkd<path><crlf>

Parameter: path is a valid path on the server side.

Example:

SendData "Mkd/users/johnsmith" + "/r/n

The return value is as follows (bold indicates success):

L 257 "PATHNAME" has been created.

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, the answer is made to all commands.

L 500 syntax error, command not recognized. This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

The L 502 command has not been implemented yet.

L 530 cannot log in.

L 550 The requested operation cannot be performed, the file is not available (for example, file not found, no access). 5. PWD (print Working directory, printing working directory) command

Description: Returns the name of the current working directory in the answer.

Usage:pwd<crlf>

Parameters: None

Example:

SendData "PWD" + "/r/n

The return value is as follows (bold indicates success):

L 257 "PATHNAME" has been created

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, the answer is made to all commands.

L 500 syntax error, unable to recognize command. This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

The L 502 command has not been implemented yet.

L 550 The requested operation cannot be performed, the file is not available (for example, file not found, no access).

6. RETR (Retrieve, retrieve) command

Description: This command lets the server send a copy of the file specified in the path name to the client. This does not affect the state and content of the file on the server site.

Usage:retr<filename><crlf>

Parameter: filename is a fully qualified path and file name on the server site.

Example:

SendData "Retr/pub/cgvb/misc/somefile.zip" + "/r/n

The return value is as follows (bold indicates success):

L 110 Reboot the tag response.

In this case, the style is accurate and will not be left to a specific implementation; it must read:

MARK yyyy=mmmm

Where yyyy is the data flow token for the user process, MMMM is the corresponding tag on the server (note the spaces between the mark and "=").

L 125 Data connection is turned on and the transfer is started.

L 150 File Status No problem, ready to open data connection.

L 226 Closes the data connection and the requested file operation was successful.

L 250 The requested file operation is working properly and is complete.

L 421 Service Unavailable, close control connection.

If a service learns that it is about to close, the answer is made to all commands.

L 425 cannot open a data connection.

L 426 Connection closes, transmission stops.

L 450 The requested file operation cannot be performed and the file is not available (for example, the file is busy).

L 451 The requested operation was aborted and a local error occurred in the processing.

L 500 syntax error, command not recognized.

This includes errors such as the command line being too long.

There are syntax errors in the L 501 parameter or variable.

This parameter is not yet implemented in the L 504 command.

L 530 cannot log in.

L 550 The requested operation cannot be performed, the file is not available (for example, file not found, no access).


log on to FTP using the cmd command-line method Upload Download Data


Some users in the use of FTP tool login space upload process often encounter a variety of problems, such as active mode, passive mode, and other causes can not log ftp, upload data, download data problems, this time may wish to use the command line. The command line can avoid many problems caused by the FTP tool configuration, and the rate of downloading data in this way is significantly faster than using the FTP tool. Here is a look at how to use the FTP command for simple upload download data.
1. Login to FTP
In the "Start"-> "Run" enter "cmd", enter the cmd command-line mode, and then enter: FTP 118.193.22.151
Enter your own web site IP address, Next prompts you to enter the FTP username: webmaster@ domain name, and then enter the password, login successful will prompt user logged in

2. View the list of all files under the current FTP space
Enter command: Dir can list files and folders in the current space and limit the disk quota to 200MB

3. Upload file
Upload the files under the D:test folder 1.txt, 2.txt, 3.txt to the Htdocs directory under the space.
Because the current directory is not necessarily in d:test, so first switch to d:test, use the command: LCD d:test, you can switch the current working directory to d:test, use the command!dir to see what the current d:test under the files, you can see 1.txt, 2.txt , 3.txt, enter the command pwd, view the current FTP directory, if not htdocs, you need to use the command CD Htdocs switch into the directory, and then use the put command to upload the 3 files separately:

To upload all txt-terminated files under D:test to Htdocs, you can use the Mput command:
Ftp> prompt to turn interactive mode off
Ftp> mput *.txt
4. Download files, download the files or folders under the space to local
Ftp> Get 1.txt

Download multiple files or folders to your local computer
ftp> mget * Download all files and folders to local
ftp> mget *.txt downloads files ending with. txt to local

5. Delete FTP space files or directories
ftp> Delete 1.txt: Delete file 1.txt
ftp> mdelete *.txt Delete all files with. txt at the end of the space
ftp> mdelete * Delete all Files


To delete a directory, you can use the RmDir directory name to delete the directory, if the directory must be empty, that is, there are no files or subdirectories in the directory. If you need to delete a non-empty directory, you need to delete the files in it before deleting the directory:
ftp> CD ABC into catalog ABC
ftp> mdelete * Delete all files in this directory
Ftp> CD ... Switch to the previous level of the directory
ftp> rmdir ABC remove empty directory ABC

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.