Why Your Curl Command Is Not Working In Windows [Solved]

Follow Us on Social Media

Why Your Curl Command Is Not Working In Windows [Solved]


How To Download Files From The Internet Through Shell (Terminal) Using Curl In Git Bash | Windows, Mac, Linux, Unix, Chrome OS



As much as you can navigate to a webpage, look for a file on the web page and download such file, you can also download internet files, web pages and source codes through the Command Line Interface (CLI).


A stock CLI usually comes preloaded with almost every OS. 

The stock CLI on Windows, is the Windows command (cmd.exe).

While for MacOS and Linux, you can access the shell through the terminal, this is not so on Windows.

For Windows, you need access to the shell through a terminal called git bash.

There are other such CLI's available for Windows windows. Another popular one is the cygwin terminal.

To download a file via shell in Windows, Mac, Linux, Unix or any other operating system, you'll need to use the curl command.

The 'curl' command which means 'see uniform resource locator', can be used to download internet files, web pages or view web source codes.

To download a file, enter the following command in your terminal:

curl -o filename.ext -L fileurl


Replace 'filename.ext' with the name you wish to save the file, and 'fileurl' with the exact location of the file on the internet.

The curl script may not work for you in Windows if you are making use of the wrong terminal to run the command.

While this command may run well on Linux or Mac, you will discover that if you try to run the command from Windows CLI the command will fail. It will also fail if you try running it from the Cygwin terminal in Windows.

I find the quick fix for this, is to run the command directly in Git Bash.

You may presume that the Git Bash path is not correctly configured in Windows 'Environment Variables'. But that's not the case. Even with correct configuration, I find the curl script does not execute as you'll get the error: 'curl' is not recognized as an internal or external command,
operable program or batch file.

Other bash scripts are running well on Windows but the curl script isn't? run it directly from bash.





No comments



Powered by Blogger.