Preface

cURL Is a common command line tool , Used to request Web The server . Its name is client (client) Of URL Tool means .

cURL The original author of is Daniel Stenberg ( At present, it is cURL The core developer of ), It's also IETF HTTPbis Senior members of the working group .Daniel stay 1998 Created in 2003 curl project , He wrote the original curl edition , And created libcurl library . up to now , Code warehouse includes 24000 Time commit More than half of them are Daniel I submitted , He is still the core developer of the project .Daniel Indicate that you have curl Think of yourself as a child .

One 、 Command installation

sudo apt-get install curl

Two 、cURL Command syntax :

curl [options] [URL...]

3、 ... and 、 command

1)、 List ftp List of directories on the server

Format :

curl ftp://www.xxx.com/ --user name:passwdcurl ftp://www.xxx.com/ –u name:passwd # Simple writing curl ftp://name:[email protected] # Simple writing 2

give an example :

for example : stay IP Address 192.168.43.117 To build FTP The server , And set the user name to user, The password for 123456
Now we want to display all the file information in the root directory of the server , The order is as follows :

curl -u user:123456 ftp://192.168.43.117

The results are as follows :
 Insert picture description here
Simple writing :

curl ftp://user:[email protected]

The results are as follows :
 Insert picture description here

2)、 List only directories , Don't show progress bar

Format :

curl ftp://www.xxx.com –u name:passwd -s

3)、 Download a file :

Format :

curl ftp://www.xxx.com/size.zip –u name:passwd -o size.zip

Examples are as follows :
Download the file from the root of the server test.c, Save to local , The local file name is also test.c.
【 Be careful 】 without -o Options , The program will direct the data stream to stdout, That is to directly display the file content to the terminal .

curl ftp://user:[email protected]/test.c -o test.c

The results are as follows :
 Insert picture description here
Simple mode

curl -u user:123456 ftp://192.168.43.117/list.h -o list.h

The results are as follows :
 Insert picture description here

4)、 Upload a file :

Format :

curl –u name:passwd -T size.mp3 ftp://www.xxx.com/mp3/

Examples are as follows :

curl -u user:123456 ftp://192.168.43.117/ -T list.h

 Insert picture description here
You can see that the file was not uploaded successfully , The return error code is 25, The meaning of the error code is :

25 FTP couldn't STOR file. The server denied the STOR operation, used for FTP uploading.

You know , It's because the server doesn't have permission to store , So set the server's write Permissions can be .

 Insert picture description here

5)、 Delete files from the server ( Use curl Pass on ftp Agreed DELE command ):

Format :

curl –u name:passwd ftp://www.xxx.com/ -X 'DELE mp3/size.mp3'

6)、 in addition curl Recursive download is not supported , But you can download files in array mode , For example, we need to download 1-10.gif Serially named files :

Format :

curl –u name:passwd ftp://www.xxx.com/img/[1-10].gif –O #O Capital letters 

7)、 To download multiple files in succession :

Format :

curl –u name:passwd ftp://www.xxx.com/img/[one,two,three].jpg –O #O Capital letters