Thursday, August 9, 2012

Running curl commands in command prompt on windows

Recently I came across the requirement of running curl commands on windows. I was trying out the rackspace (www.rackspace.com) Open Stack API (http://docs.rackspace.com/servers/api/v2/cs-devguide/content/ch_api_operations.html) on windows. I thought downloading curl.exe was all I needed but turned out I needed to install Cygwin as well. This was because running curl commands on windows command prompt gave me annoying "unmatched close brace/bracket" error messages. Cygwin allows you to run linux style commands on windows inside a Cygwin terminal (see their documentation for details).

So here are the steps I followed :

1. Download curl for windows from http://curl.haxx.se/download.html. Extract the zip file and copy the path to curl.exe. You will need this later.
2. Download setup.exe from http://cygwin.com/. Running this file will guide you through the Cygwin setup.
3. I used all the default settings in the setup wizard for Cygwin except for in the 'Select Packages' dialog, I specifically selected 'curl' which is under the section Net (see image below).

4. After setting up Cygwin I launched the Cygwin Terminal and used the cd command to change directory to the folder having curl.exe. You can use the path you copied in (1).
5. Now you can directly run curl commands inside the Cygwin Terminal :)