Pinterest Stumbleupon Whatsapp
Ads by Google

google command lineIf you use YouTube, Blogger, Picasa, Google Docs, Google Contacts, or Google Calendar, some recent news from the Open Source at Google blog might pique your interest: you can now use all of these Google services from the command line.

Yes, the command line – that sexy, monochrome, text-based terminal where hackers do their dirty work in movies – and now you can show your friends just how hardcore you are by uploading your photos to Picasa with it.


GoogleCL is an Google command line application written in Python that allows you to make Google Data API calls from the command line, and all jokes aside, can actually be very useful if you’re writing scripts to interact with the aforementioned Google services.  In this guide, I’ll give you a tour of GoogleCL with some examples to get you started.

Getting Started

Note: This guide is going to be very technical. If you are not familiar with working in a command line environment, editing system path variables, or creating batch scripts, you should not proceed.

First, the tough part. GoogleCL can be used in Windows, Linux, and Mac operating systems, but there are a few prerequisites before you can get started.  If you have any problems with this guide, make sure to check out GoogleCL’s system requirements page for more information.

Google Command Line for Windows Users

Windows users have to follow a few extra steps to make this work. The following information is based off instructions from public int’s instructions (but hopefully a little easier to follow).

  1. Download and install Python – I’m using version 2.6.5 in this guide and selected the default settings when I installed it. You’ll need at least Python 2.5 installed, and if you already have Python you can use the python ““V command to see what version you’re using.
  2. Add the directory where you installed Python to your Windows PATH.
    • Windows 7/Vista: Right click My Computer, select Properties, and click Advanced system settings. Click Environment Variables, select Path under System Variables and click the Edit button. Separate the new entry by adding a semicolon (;) then type the location to your Python location.  In my case, I added ;C:/Python26 to my Path variable.
      python-path
    • Windows XP: Right click My Computer, select Properties, and click the Advanced tab. Click the Environment Variables button, select Path under System Variables and click the Edit button. Separate the new entry by adding a semicolon (;) then type the location of your Python directory.
  3. Download the gdata-python-client library and the GoogleCL application.  Extract the contents of both of these files and note their location. (Note: gdata-python-client is available as a .zip but GoogleCL is only in .tar.gz format – 7-zip is a great free application to extract these).  I extracted these files right in my Downloads folder.
  4. Open the Windows Command Line tool by clicking Start ““> Run and typing cmd. You can also access this by pressing the WIN key + R and then typing cmd.
  5. Navigate (using the cd command) to the folder where you extracted the gdata-python-client and GoogleCL files from Step 3 and issue the following commands (make sure to change the folder names as necessary):

cd gdtata-2.0.10

setup.py install

cd ..

cd googlecl-0.9.7

setup.py install

Ads by Google

Finally, you can make a “google” command line script to easily launch GoogleCL. Create a blank text file, enter the following information (making sure to change the bolded part to the location where you saved the GoogelCL files in Step 2), and save the file as google.cmd in the folder where you installed Python (mine being C:/Python26).

@echo off

set googlecl_home=D:\Downloads\googlecl-0.9.7\src

python %googlecl_home%\google %*

Now you can type a command like google docs list in your command line to bring up a prompt for your username.

After you type your username, you’ll be taken to a browser page where you need to grant access for GoogleCL to access your information. You will only need to authenticate each service once.

Finally, go back to the command line and press Enter. You did it! GoogleCL should now be working, so give yourself a high five. If you have problems, refer to public int’s guide or check out PCWorld’s guide for alternate instructions using Cygwin.

Mac and Linux Users:

  1. Download and install Python. You’ll need at least Python 2.5 installed, and if you already have Python you can use the python ““V command to see what version you’re using.
  2. Download the gdata-python-client library and the GoogleCL application. Extract the contents of both of these files and note their location.
  3. In a Terminal window, navigate to the folder where you extracted the files from Step 2 and issue the following commands (make sure to change the folder names as necessary):

cd gdata-2.0.10

sudo python setup.py install

cd ..

cd googlecl-0.9.7

sudo python setup.py install

Using GoogleCL

Now that we’ve gotten through the bad stuff, it’s time to have some fun with GoogleCL!

Creating a Blogger post

Your blog will gain an infinite amount of nerd-cred if you post to it via command line.  Use the following command to post directly to your blogger account:

google blogger post –title “Your Title” “Your content”

Press enter when you’re finished, and you’ll have this:

Using your Google Calendar

To view events on your Google Calendar, use the following command and specify a date range, separated by commas, after –date.  In the example below, I’ll list events for the month of May.

google calendar list –date 2010-05-01,2010-05-31

You can easily add events to Google Calendar with the following command:

google calendar add “Collapse after writing article about GoogleCL today at 11pm”

Create a text document in Google Docs

You can easily create and edit Google Docs from the Google command line with the following command. You’ll have to specify a text editor in this command – Linux users can use Vim The Top 3 Free Coding Text Editors For Mac OS X The Top 3 Free Coding Text Editors For Mac OS X Read More (which keeps you in the command line) and Windows users can use Notepad. Save the document when you’re finished and it will be uploaded to Google Docs!

google docs edit –title “Your Title” –editor Notepad

google command line

And much more”¦

There are many more functions available in GoogleCL – check out some of Google’s example scripts to learn the basic syntax and start experimenting.  GoogleCL’s functionality will only be increasing as more APIs are available, so keep an eye out for good things to come.

Now that you’ve gotten a crash course in GoogleCL, I hope to see you sharing some creative code in the comments!

Leave a Reply

Your email address will not be published. Required fields are marked *