Knowledge Base

How to use the cURL program

This article describes how to use the cURL program to transfer files from the command line.

When to use cURL

If you need to transfer a file quickly from the command line, the cURL program is often the easiest way to do so. For example, you might need to download a .zip file or .tar.gz file that contains a code library for a project you are working on. With cURL, you can download the file directly to your account, instead of having to use an FTP client to download and transfer the file to your account.

For security reasons, we do not provide access to the wget program on shared hosting accounts. If your application absolutely requires the wget program, submit a support ticket on the Customer Portal at https://my.a2hosting.com. In the ticket, please explain why you need access to wget, and we will try to accommodate you.

How to use cURL

To start cURL, log in to your A2 Hosting account using SSH, and then type the following command:

curl

However, this command by itself does not accomplish much. Let's download a page from the example.com test domain:

curl -O http://example.com/test.html

Curl downloads the page to the current working directory. The -O option instructs cURL to download the output and save it in a file name that has the same name as the source document. In this case, it is test.html. If you open the test.html file on your account, you can see the HTML source page for example.com/test.html.

If you want to download a file and assign it a specific filename, use the -o option. For example, to download the example.com/test.html file to a file on the local account named download.html, type the following command:

curl -o download.html http://example.com/test.html

More Information

There are many more options available for the cURL program. To learn about them, type the following command:

man curl