Install and Set Up kubectl. The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters.You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. we use Mac OS X 10.8 and Xcode 4.5.2. Here we try now to create our first simple (Cocoa Application) example with the curl-library. We will download an file with this library and place the downloaded file to a special place. Enclosed I'll send you the code we use until now.

We often have to download various files from the Internet, for example, executable program files, script files, archives with source codes. But it is not always necessary to do this through the browser. In many situations it is much easier to perform all actions through the terminal. Because this way you can automate the process. On the other hand, webmasters from time to time have to test the availability of websites, check the sent and received headers, and more.

To solve such problems and tasks of such a circle, you can use the curl utility. It allows you to solve a much wider range of tasks, among which even an imitation of user actions on the site. In this article we will look at how to use curl, what it is and why we need this program.

What is CURL?

In fact, curl is more than just a command line utility for macOS, Linux or Windows. This is a set of libraries that implement the basic capabilities of working with URL pages and file transfer. The library supports working with protocols: FTP, FTPS, HTTP, HTTPS, TFTP, SCP, SFTP, Telnet, DICT, LDAP, as well as POP3, IMAP and SMTP. It is great for simulating user actions on pages and other operations with URL addresses.

CURL Utility

Before proceeding to the description of how the curl linux command can be used, let’s take a look at the utility itself and its main options that we need. The utility syntax is very simple:

Use CURL to Download File

The most common task is downloading files. Download the file is very simple. To do this, simply transfer the file name or the html page to the utility in the parameters:

But here you will find one surprise, the entire contents of the file will be sent to the standard output. To write it to any file use:

Read more: How to Create a Tar GZip file via Terminal?

Use CURL to Download Multiple Files

If necessary, one command can download several files:

Use CURL for File Transfer

Uploading files is quite simple, but the utility allows you to perform other actions, such as sending files to an ftp server. For this there is an option -T:

Authentication with CURL

If the server requires authentication of one of the common types, for example, HTTP Basic or FTP, then curl can very easily cope with this task. To specify authentication data, simply enter them with a colon in the -u option:

Using Proxy

If you need to use a proxy server to download files, then it is also very simple. It is enough to set the proxy server address in the -x option:

CURL’s Options

Now consider the main options:

-a, –append Append to target file when uploading (F/SFTP)

-E, –cert CERT[:PASSWD] Client certificate file and password (SSL)

-K, –config FILE Read config from FILE

-C, –continue-at OFFSET Resumed transfer OFFSET

-b, –cookie STRING/FILE Read cookies from STRING/FILE (H)

-c, –cookie-jar FILE Write cookies to FILE after operation (H)

-d, –data DATA HTTP POST data (H)

-D, –dump-header FILE Write the received headers to FILE

-f, –fail Fail silently (no output at all) on HTTP errors (H)

-F, –form CONTENT Specify HTTP multipart POST data (H)

-P, –ftp-port ADR Use PORT with given address instead of PASV (F)

-G, –get Send the -d data with a HTTP GET (H)

-g, –globoff Disable URL sequences and ranges using {} and []

-H, –header LINE Pass custom header LINE to server (H)

-I, –head Show document info only

-h, –help This help text

-0, –http1.0 Use HTTP 1.0 (H)

-i, –include Include protocol headers in the output (H/F)

-k, –insecure Allow connections to SSL sites without certs (H)

-4, –ipv4 Resolve name to IPv4 address

-6, –ipv6 Resolve name to IPv6 address

-j, –junk-session-cookies Ignore session cookies read from file (H)

-l, –list-only List only mode (F/POP3)

-L, –location Follow redirects (H)

-M, –manual Display the full manual

-m, –max-time SECONDS Maximum time allowed for the transfer

-n, –netrc Must read .netrc for user name and password

-:, –next Allows the following URL to use a separate set of options

-N, –no-buffer Disable buffering of the output stream

-o, –output FILE Write to FILE instead of stdout

-#, –progress-bar Display transfer progress as a progress bar

-x, –proxy [PROTOCOL://]HOST[:PORT] Use proxy on given port

-U, –proxy-user USER[:PASSWORD] Proxy user and password

-p, –proxytunnel Operate through a HTTP proxy tunnel (using CONNECT)

-Q, –quote CMD Send command(s) to server before transfer (F/SFTP)

-r, –range RANGE Retrieve only the bytes within RANGE

-e, –referer Referer URL (H)

-J, –remote-header-name Use the header-provided filename (H)

-O, –remote-name Write output to a file named as the remote file

-R, –remote-time Set the remote file’s time on the local output

-X, –request COMMAND Specify request command to use

Conclusion

This article describes the basic commands for working with CURL. If suddenly you want to expand your knowledge of working with the utility, check the table above or type this command in Command Line:

In this article we looked at how to use curl, why we need this utility and its main features. Despite their similarity with wget, they are very different. The curl command is designed more to analyze and simulate various actions on the server, while wget is more suitable for downloading files and crawling sites.

What is cURL?

cURL is a command-line tool that lets you transfer data to/from a server using various protocols. In this case, the curl command will establish a communication to POST or GET data to/from Ubidots Server over HTTP and HTTPS.

Application

Below you will find the step-by-step to installing cURL in Windows, MacOSX and Linux.

Step-by-Step

  1. Windows installation
  2. MacOSX installation
  3. Linux installation

1. Windows Installation

1. Enter and access the URL https://curl.haxx.se/ to download the curl executable wizard.

2. Select 'curl executable' as Type of Package.

3. Then, on the 'Select Operating System' section, select Windows. Then, continue selecting the parameters required based on your version of Windows.

4. Once you've finished the on-screen steps, download the zip file generated. To download it, simply press 'Download'.

5. Next, open the .zip file and enter to the folder called 'src*'. Inside the src folder you will find the curl executable file. At this point, you need to copy the executable file and paste it inside a local folder on your PC to be able to run the curl.

Curl Download To Application Folder Mac Os X 10.6

NOTE: To get a better understanding of the following steps, let's assume the executable file is located inside a folder named 'programs'.

6. From the Command Prompt, enter to the location where the executable file was pasted. To enter to the folder you need to use the cd command following the location of the folder which contains the executable file as you can see below.

Expected location to be shown

7. To verify if you are able to run curl commands with the command prompt, test functionality by executing the command below:

At this point, you should receive the all the help info related to the curl command.

[Troubleshooting] If you experience errors in the downloading process, please refer to this video for additional troubleshooting.
Now you are able to use cURL from your Windows pc!

2. MacOSX Installation

1. Enter to the computer's terminal.

2. Run the command below in the terminal:

Curl Download To Application Folder Mac Os X

Curl Download To Application Folder Mac Os X 10.10

3. If a password is required after running the command, please enter your Mac's user password to continue. Then, wait until the installation finish.

4. Run the command below in the terminal:


Now you are able to use cURL from your Mac pc!


3. Linux installation

Curl Download To Application Folder Mac Os X And Copy Paste

1. Enter to the computer's terminal.

Curl Download To Application Folder Mac Os X 10.8

2. Run the command below in the terminal:

3. If a password is required after ran the command, please enter your computers' user password to continue. Then, wait until the installation finishes.

Now you are able to use cURL from your Linux pc!