Using Cygwin to run a shell script for ip2cc Drupal module with Netbeans

Sometime ago, it was hell for me to practice UNIX commands. I had taken the pain of installing multiple Operating Systems either through hard disk partitioning or through the much embrassed virtualization tools such as Sun VM, VMWare, just to get an environment to practice UNIX commands. But there comes Cygwin. The Linux-like environment for Windows. The UNIX environment for windows.



In this tutorial, I am going to explain how to use this powerful Windows tool to run the ip2cc Drupal module. The ip2cc drupal module is an API for retrieving country related information from a given IP address.



Todo Tasks


  1. Download cygwin setup.exe if you have not and set the path Cygwin installation.
  2. Activate the C/C++ module in Netbeans.
  3. Install unzip, wget packages using the Cygwin installation program
  4. Run the ip2cc script.


Download Cygwin setup.exe


The Cygwin program has a singular setup file that you can run more than one time to perform tasks such as package installation, re-install, and uninstall. Yo download the Cygwin program, click here


After the download is complete;

  • click Next until you get to the "Local Package Directory screen".
  • Set the directory you would like to download the Cygwin packages. Note: This directory is a temporary directory. The packages won't be installed in this directory but in the etc/setup directory of your Cygwin program location.
  • Click Next until you get to the "Choose A Download Site" screen.
  • Choose the download site nearest to you.
  • Click Next
  • Install the basic packages from the devel category: select gcc-core: C compiler, gcc-g++: C++ compiler, gdb: The GNU Debugger, and make: the GNU version of the 'make' utility.

Since, this help tip is concerned with Windows environment for the Cygwin program, set the PATH to the Cygwin installation. To do this;

  • Launch the Windows Environment program. Press the [windows-key+PAUSE BREAK] to launch
  • Add the path to the cygwin-directory\bin directory to the Path variable and click OK all the way



Activate the C/C++ module in Netbeans


If you downloaded Netbeans with the C/C++ module bundle, the C/C++ module gets activated automatically. However, if you don't have the C/C++module, you can download it using the Netbeans Plugins Manager.


Install unzip, wget packages using the Cygwin installation program

To do this;

  • Run the Cygwin setup file again
  • Click "Next" until you get to the "Choose A Download site" screen.
  • Click Note that the unzip package is not available in all mirrors, you might have to search for yourself. However, I was able to find it at the mirror site. If you can't find the mirror site, use the mirror site.
  • Click the Archive category to find the unzip package
  • Click the web category to find the wget.

 Cygwin unzip package install screnshotCygwin wget package install screenshot


Run the ip2cc script


  • Open the Cygwin program (Start->All Programs -> Cygwin -> Cygwin Bash Shell)
  • cd to [path-to-drupal]/sites/all/modules/ip2cc
  • Run the command Note: if you get the command not found error, that's because you have not set the path to your current working directory. So, to bypass this error, run the command, ./


Voila, You have just downloaded and extracted the ip-to-country.csv file into the ip2cc directory. You can go ahead and enable the module.



Post new comment

The content of this field is kept private and will not be shown publicly.