Curl linux to windows

How to Install and Use curl on Windows

curl is a command-line utility used on Windows, Linux, and Mac OS to transfer and receive data via various protocols, including HTTPS, SMP, FTP, SFTP, alt-svc, CA Extract, HSTS, SSL Certs, and SSL libs compared, and many more. All transfer-related functionality in curl is powered by libcurl, which is a client-side URL transfer library.

The instructions required for the installation of curl on Windows will be illustrated in this blog.

curl Installation on Windows

Follows the below-listed procedure to install curl on Windows.

Step 1: Download curl Installer File

First, download the curl installer file for curl installation by visiting the below-provided link:

Press “CTRL+F” to view the search menu and type out “Windows” as shown in the highlighted bar. Then, download the curl installer file according to your system specifications. For instance, we have selected the “Windows 64 bit” binary setup file:

Within a few minutes, the “curl-7.84.0_4-win64-mingw.zip” setup file will be downloaded and saved in the “Downloads” folder:

Step 2: Create a “Curl” Folder

In the next step, create a new folder named “Curl” in the C drive:

Step 3: Paste Setup Folder Into “Curl” Folder

Go to the “Downloads” directory where the curl zipped folder is saved:

Before copying the curl setup folder, extract it first using right-click menu:

Select the extracted folder and press “CTRL+C” to copy it:

Then, move to the newly created “Curl” folder in the C drive, open it, and press “CTRL+V” to paste the copied setup folder:

Step 4: Find and Copy curl Setup Path

Open the curl setup folder and go to the “bin” folder to find the curl.exe file:

After finding the required curl.exe file, right-click on the folder path for copying it:

Step 5: Set Path in Environment Variables

After copying the curl setup file path, go to the “Startup” menu, search for “Environment Variables”, and open it from displayed results:

Upon doing so, the “System Properties” window will appear. Click on the “Environment Variables” button:

Select the “Path” from the “System variables” section and click on the “Edit” button:

After that, click on the “New” button and paste the copied curl setup file path as shown in below highlighted output. Then, click on the “OK” button:

At this point, we have successfully installed and configured curl on our Windows system. Let’s verify curl installation by checking its version.

Step 6: Verify curl Installation

First, open up the command prompt using the “Startup” menu:

Type the below-provided command in the opened window to verify curl’s version:

As you can see, we have successfully installed curl version “7.78.0” on Windows.

Читайте также:  Установка yandex browser alt linux

curl Usage on Windows

On Windows, to use curl, check out the below-listed examples.

Example 1: Get URL Homepage

You can use the curl command along with the URL to get and print the Homepage of any website. For instance, the following curl command will get Google homepage:

Example 2: Get Header Information

To get the header information of any website, use the curl command with the “-i” option and provide the URL:

The given output displayed the header information of the Google website:

Example 3: Download Setup File

Want to download a setup file? Utilize the curl command and specify the URL of the required file:

Example 4: Get Help

When a curl command is executed with the “–help” option, it prints out its manual on the command prompt:

We have demonstrated the methods to install and use curl on Windows.

Conclusion

To install the curl command-line utility on Windows, first, download the installer setup file. After that, make a new directory curl in the “C” drive and paste the setup into the newly created curl folder. Then, find and copy the setup path and set it in the Environment variables as discussed earlier. This blog has effectively elaborated the method to install and use curl on Windows.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.

Источник

How to install cURL on windows and how to use it

curled plant stem

This article describes how to install and use CURL on Windows. Curl is a free command line utility used for transferring files using various protocols. Most commonly it is used for transferring files over HTTP(S).

cURL comes natively installed on Unix based operating systems such as MacOS and Linux. But windows is left out. Now that we have PowerShell on windows, you can get some of the functionality of cURL using various cmdlets like invoke-webrequest. However, if you are used to using a Unix toolset, you will be left wondering where you can find cURL.

Methods of Installing cURL

To install cURL on windows, you have five real options:

  • Install using Chocolatey ( Windows Package manager)
  • Download pre-compiled Binaries
  • Compile from source code
  • Install Cygwin
  • Install Windows Subsystem for Linux (WSL)

In the next few sections, we will discuss each of the above installation methods.

Chocolatey Package Manager

If you want to go the Chocolatey route, it is really simple, just run:

This will install cURL for you. However, you need to first install the Chocolatey package manager. You can find instructions on how to install Chocolatey here.

Download Pre-Compiled cURL Binaries

cURL is supported on many platforms. And if you navigate here, you will see binaries you can download for many different platforms. All the way at the bottom of the page you will find the windows builds. They are all labeled as Win32 or Win64

I recommend you download the zip file in the Win64 – Generic section:

curl download screenshot

After you have downloaded and extracted the zip file, look in the src folder, you will find curl.exe. Copy curl.exe into your C:\windows\system32\ folder. I choose this folder because it includes all of the other system utilities. And it is already part of your PATH variable, so you don’t have to do anything to add it.

Читайте также:  Vmware astra linux настройка сети

Compile from Source Code

This is the hardest method of installation. If you are trying to get things up quickly, you should skip over this section. But, for those who want to do it just for the experience, or those who absolutely need the latest version, building from source code might be the method for you. You can find instructions on how to install from source code here: https://curl.haxx.se/docs/install.html

Install CYGWIN

CYGWIN is a Unix-like environment for Windows. You can’t natively run all of your favorite Unix tools on Windows. First, you have to download the source code and compile it to run on windows. Just like in the previous section. CYGWIN is a project where someone has gone through the work to pre-compile many of your favorite Unix tools for you.

To use cURL as part of CYGWIN, you first download and CYGWIN installer from here. While you are going through the installer, you will encounter a list of packages you wish to install. Make sure you select the cURL package.

Install Windows Subsystem for Linux (WSL)

Starting with Windows 10, Microsoft has released a product called Windows Subsystem for Linux (WSL). WSL gives you the bash command shell on windows, which is the same shell that runs on Linux/Unix. Installing WSL gives you a full Linux environment, unlike CYGWIN which is simply a collection of Unix utilities. WSL is based on Ubuntu Linux. So you will have tools like apt-get to install programs etc…. The main limitation of WSL is you don’t have a GUI. But that is fine for our purposes today.

Older builds of Windows 10 will have to enable Developer mode before they can install the windows feature. You can find instructions on how to do that here.

Starting with the windows 10 Fall Creators update, you don’t have to enable Developer mode. However, it is still a two-step process. First, you enable the windows feature. Then you install the Linux distribution from the windows store. instructions can be found here.

After you have installed WSL, go to your Start menu, click on Bash, and you can use all of your favorite Linux tools, including cURL.

How to use cURL on Windows

As this guide is about installing cURL, I won’t go into great detail about using curl. However, here are some basics. Each of these commands will largely work the same way on both Windows and Unix variants.

First, you need to launch the appropriate command line environment. If you installed WSL or CYGWIN, you will need to go to your start menu and launch CYGWIN or BASH. Otherwise, you can launch a command prompt or Powershell window.

The above command will show you all the different command arguments you can pass to cURL. This will be very important as you are learning how to use the tool.

Lets try pulling down the text of a webpage using curl with the following command:

You should see all the HTML code from idkrtm.com scroll by…that means it is working.

How to download website headers with curl

Next, let’s just pull down the headers. This is useful for just checking if a web page is working. If you’re on Linux, OSX/MacOS, CYGWIN, or WSL, the command would be:

curl -s -D - http://54.184.76.36 -o /dev/null

the output should be similar to this:

Читайте также:  Linux find all files with date

HTTP/1.1 200 OKDate: Mon, 12 Feb 2018 15:25:35 GMTServer: ApacheX-Powered-By: PHP/5.5.38Link: ; rel=”https://api.w.org/”, ; rel=shortlinkTransfer-Encoding: chunkedContent-Type: text/html; charset=UTF-8

On Windows Powershell, the same command would be:

curl -s -D - http://54.184.76.36 -o $null

Or on Windows CMD, the same command would be:

curl -s -D – http://54.184.76.36 -o nul

cURL Post request

When you make post requests, there are three kinds of posts you will probably make

For these three operations, we will need the -d, -x and -h CLI arguments. Here is an example of how we would post variables

curl -d "key1=value1&key2=value2" -X POST http://localhost

In the above example, we start by calling the curl command, then using the -d argument for data. Within the quotes, we pass in the 2 URL parameters we want to pass to the server. We then use the -X argument to tell cURL that we are going to make a post. Then we pass in the URL of the server we want to post to.

In the next example, we will post a file to the same URL

curl -d "@myfile.txt" -X POST http://localhost

This example is very similar to the original example. We use the same -d and -X arguments. But within the quotes we used @myfile.txt . This will upload myfile.txt from the current working directory and post it to the URL we specified

In the next example, we will pass in JSON to the same endpoint. You will notice in this example, we are passing in the -H parameter.

curl -d '' -H "Content-Type: application/json" -X POST http://localhost

You can see this is very similar to the previous two examples. However, we passed in JSON within the quotes, and we added a Content-Type:application/json header to the input. We did not have to do this in the previous examples, because the other examples were able to use the default content type: “Content-Type: application/x-www-form-urlencoded”

As you can imagine, the JSON you pass in can get quite large, so you can also pass in a JSON file

curl -d "@myfile.json" -X POST http://localhost

As you are interacting with websites, it is only a matter of time before you encounter one where you need to authenticate. Similar to how you authenticate in your browser. cURL supports a variety of authentication methods, but today we will only cover basic authentication, which is very easy. See the example below.

curl -u myusername:mypassword http://localhost

In the above example, we added a -u parameter for username. We then separated the username from the password with a colon.

Thank you for stopping by today. We discussed five different ways to install cURL on your windows computer. And some of the most common commands you might need to use with cURL.

As you can see, cURL is a very flexible tool that can work on both Windows and Unix variants of operating systems. If you want to know a lot more about cURL, there is a free book on GitHub, called Everything Curl, that goes into great detail about everything you want to know about cURL.

Share this:

Источник

Оцените статью
Adblock
detector