Introducing the Google Command Line Tool
Friday, June 18, 2010 | 8:55 AM

Ever wanted to upload a folder full of photos to Picasa from a command prompt? We did, a lot, last summer. It made us want to say:$ google picasa create --title "My album" ~/Photos/vacation/*.jpg
So we wrote a program to do that, and a whole lot more.
GoogleCL is a command-line utility that provides access to various Google services. It streamlines tasks such as posting to a Blogger blog, adding events to Calendar, or editing documents on Google Docs.
For example:$ google blogger post --blog "My blog" --tags "python, googlecl, development" my_post.html $ google calendar add "Lunch with Jason tomorrow at noon"$ google docs edit --title "Shopping list" --editor vim
GoogleCL is a pure Python application that uses the Python gdata libraries to make Google Data API calls from the command line.
Read more at the GoogleCL project page, or jump right to the examples. Along with a standard tarball, we have a .deb package ready for download, and hope to have it included in Debian and Ubuntu repositories in time for their next releases. We're adding features all the time, so check in frequently. Or better yet, contribute.
GoogleCL brings cloud computing to your fingertips, literally!
By Jason Holt, Street View Team and Tom Miller, former Street View Intern

90 comments:
Firoze said...
Wow, I've needed this for a while. I've had to write bits and pieces of it myself. Thanks!
June 18, 2010 11:16 AM
nomical said...
Not really. I don't know how to program and don't care to start. Wish we could upload a folder to Picasa right now as opposed to individually uploading each item (if we don't have Picasa desktop).
Props for more options though, and also for opening up comments when most Google blogs are closed.
June 18, 2010 11:31 AM
MarkDalrymple said...
If you're on a Mac, you can use the Picasa Web Albums Uploader. http://www.google.com/mac/
If you use Lightroom or Aperture, you can get plugins that'll upload to Picasaweb from inside the app.
June 18, 2010 11:42 AM
wugunz said...
Nice!
June 18, 2010 11:44 AM
Shantanu said...
Awesome!! Thanks :)
June 18, 2010 11:50 AM
RBerenguel said...
Looks nice. Have you ever used goosh.com (the unofficial google shell)? You probably would like it!
Ruben
June 18, 2010 11:50 AM
Geoff said...
@nomical Um.. did you read the example commands at all? What you asked for is exactly what one of the sample commands does.
June 18, 2010 11:59 AM
Roadnottaken said...
would be great if you could also do standard google web-searches via the CL, and presumably get a list of plain-text results back. more-often than not i don't even need to follow the result links, the summary text usually tells me what I want...
June 18, 2010 12:15 PM
steven said...
It would be nice to see this in the Google Linux repos (http://www.google.com/linuxrepositories/)
June 18, 2010 12:18 PM
Schitso said...
Effing amazing.
June 18, 2010 12:41 PM
simukti.info said...
wow... it's a good news...!!
June 18, 2010 12:45 PM
eternal1 said...
Wow!
June 18, 2010 12:52 PM
Devin said...
Great idea!
June 18, 2010 1:11 PM
alienz said...
I love it!
June 18, 2010 1:11 PM
Fisa said...
I love you!! This couldn't be better!!
June 18, 2010 1:13 PM
Dan said...
@RoadNotTaken, this python script will do that for you. If you call the function, it will search for the string contents of arg and print the first blurb. To access more than the first result, change results[0] to some sort of loop.:
def execute(arg = ''):
# Requires simplejson module for AJAX search
# from:http://pypi.python.org/pypi/simplejson
# Example code found at: http://dcortesi.com/
import urllib
import simplejson
import re
import unicodedata
if arg == '':
return 'Error: No search string.'
query = urllib.urlencode({'q' : arg})
url = 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&%s' % (query)
search_results = urllib.urlopen(url)
json = simplejson.loads(search_results.read())
results = json['responseData']['results']
try:
ret = re.sub(r'<[^>]*?>', '', results[0]['content']) # Strips HTML formatting
except:
return "There was an error parsing data. Please try again."
ret = re.sub(r'&[^ ]*?;', '', ret) # Strips HTML special characters (ie. " )
return unicodedata.normalize('NFKD', unicode(ret, "utf-8")).encode('ascii','ignore')
#return unicodedata.normalize('NFKD', ret).encode('ascii','ignore')
June 18, 2010 1:13 PM
Jim Ramia said...
excellent !
June 18, 2010 1:20 PM
Jeff Kelley said...
Shouldn't they be split up into several command-line utilities? For instance, "picasa" instead of "google picasa"? That would allow crazy things, like "cat Desktop/post.txt | blogger".
June 18, 2010 1:25 PM
webguy said...
LOVE this.
June 18, 2010 1:27 PM
Timothy Lee Russell said...
Embed android-scripting in your Android Market app.
Run GoogleCL on top of it and you've got something!
I don't know what it is -- but it's something.
June 18, 2010 1:31 PM
James Salsman said...
You might want to link to gdata from http://code.google.com/p/gdata-python-client/downloads/list
June 18, 2010 1:47 PM
Sheldon said...
Awesome
June 18, 2010 1:48 PM
Malicious Monkey said...
@Roadnottaken
Make sure you have w3m installed, and then put the following in a file called "search" (or whatever you like):
#!/bin/bash
wget http://www.google.com/search?q="$*" -U "FakeBrowser 9000" -O - | w3m -T text/html -dump
Then do "chmod a+x search". Now you can say things like:
./search foo bar baz
June 18, 2010 1:50 PM
Shane Conder said...
Ooh, I hope it's not April 1 today. *calendar check* Wow, nope!
Really nice!
There goes my Friday evening...
June 18, 2010 1:52 PM
Ing. Juan Ignacio Zamora M, MSc. said...
This will have enormous commercial applications.
June 18, 2010 2:34 PM
Kris J said...
Superb! CLI FTW!
June 18, 2010 2:38 PM
GoodDamon said...
Is there any plan to add Google Voice support?
June 18, 2010 2:53 PM
Sanjaya Yogi said...
This google commandline tool is very useful! Thank you for pointing it out.
@Roadnottaken:
To scrape an individual web page:
Create a file:
nano scrape
#!/bin/sh
wget $1 -U "FakeBrowser 9000" -O - | w3m -T text/html -dump > $2
chmod a+x scrape
To use:
scrape arg1 (a URL) arg2 (output to a file)
Example:
scrape dcortesi.com/ dcortesi
cat dcortesi
Gives you a text dump of the web page.
June 18, 2010 2:58 PM
coldacid said...
Not using it until I can easy_install it.
June 18, 2010 3:07 PM
eventides said...
Is it possible to export reports from Google Analytics?
June 18, 2010 3:37 PM
Anonymous Coward said...
Roadnottaken, you have been able to do this forever with the console browsers of links, lynx, w3c, wget or curl. The last two need you to be a little creative (knowing sed and awk helps) but the first 3 just need you to read the man page and know how to search in google from an url ( http://www.google.com/search?q=puppy%20dogs ). You could wrap the final result into a bash script though I would use php for urlencode (to make sure items like space are replaced with %20) which can also be run on the command line and hence inside a bash script as well.
June 18, 2010 4:12 PM
joris said...
While it's an awesome idea, it really needs support for search and mail before I can call it handy. I mean, of all Google services, aren't those two the most used? and the easiest accessible from commandline, too? I love my commandline, but for images, video, docs, ... I prefer some sort of GUI with a WYSIWYG thing going on...
June 18, 2010 4:14 PM
jholt said...
easy_install should work now. please file an issue if you have trouble.
http://code.google.com/p/googlecl/wiki/SystemRequirements
June 18, 2010 4:14 PM
Jorick said...
@coldacid
That's what a .deb is for (providing you're on a Debian based system)
June 18, 2010 5:01 PM
Sam Liang said...
How to run this CL on an Android phone?
June 18, 2010 5:21 PM
karnage said...
wait..so I can edit a Google Doc from the command line, but there is still no proper means of editing it on Android?
June 18, 2010 6:26 PM
Dhiraj said...
Another failure
waste of time and prettty useless
June 18, 2010 6:33 PM
Max Thrun said...
Awesome! Was just looking the other day for way to upload images easily to picasa
June 18, 2010 6:37 PM
Bilgee said...
It seems like linux :) good work
June 18, 2010 7:07 PM
ndepalma said...
Google tasks interface pleez
June 18, 2010 7:25 PM
Brian Herman said...
Can you make it work with cygwin?
June 18, 2010 7:28 PM
PhotoHand said...
Kinda geeky for an ordinary consumer.
June 18, 2010 8:43 PM
najmi said...
hemm for google calendar how exactly i can specify the date that I want to put task. using$ google calendar add "Matlab training @ Sheraton" --date 2010 -06-22 put the date to TODAY ... put this in the feature bugrequest. TQ
June 18, 2010 9:03 PM
asraikhn said...
Awesome I'll give it a try on Fedora 12 box.
June 18, 2010 10:16 PM
Anthony Fejes said...
Dammit... too bad I just abandoned blogger because it no longer supports FTP publishing.
June 18, 2010 10:23 PM
Anthony Fejes said...
Dammit... too bad I just abandoned blogger because it no longer supports FTP publishing. Oh well.
June 18, 2010 10:23 PM
Socially Active said...
Wonderful, I can now script my pics syncs and fast up load blogs.
This is not too geeky. It is handy and fast. And saves much of the browser overhead for embedded applications.
June 18, 2010 10:38 PM
Daniel H said...
Sweet bash, thanks! If only i had Wifi or 3G on my e1000d i could make pictures appear online as soon as i take them.
Hello weekend :D
June 18, 2010 11:29 PM
Sharpie said...
@ Brian Herman:
Should work on any platform for which you have python installed. It is already in the cheese shop, I was able to get it via:
pip install gdata
pip install googlecl
Of course, you can use easy_install instead of pip if you like.
June 18, 2010 11:59 PM
seoer said...
Well this look exactly like Goosh.org, the only difference is that the author allowed us using Google by command line since 2008.
Aren't you a bit later for this?
June 19, 2010 1:14 AM
thegzeus said...
I hope that this will be extended (with the possible necessity of a fork) to work with more video/photo services.
June 19, 2010 1:38 AM
karlili said...
WOW i love that....
can we have the command line to read gmail too/ ?
i missed the console mode display =P
June 19, 2010 1:45 AM
nXqd said...
Amazing :D
June 19, 2010 2:11 AM
jaCoder said...
Tremendous!
It's a logical next step to desktop-web integration. No, better to say it's a leap!
June 19, 2010 2:18 AM
jaCoder said...
How fast new APIs will be added? How full will be the pallette of supported Google APIs?
Actually, only GData-based. What about the long-term perspective?
June 19, 2010 2:30 AM
Lord Juan said...
Sweet!
June 19, 2010 4:17 AM
Tomas said...
it seems great, i hope you will add support for analytics and adwords and search of course. An i hope it will be possible to create some complex queries with combination of those services. And it could be online service btw - e.g. i think it should not be a problem to program it so you could use standard google.com input box
June 19, 2010 5:24 AM
coirius said...
I love it!
June 19, 2010 5:48 AM
scavenger said...
Absolutely aweable :)
June 19, 2010 6:10 AM
Shekhar Sahu said...
I haven't started with python yet, but will surely do it. Thanks to team.
June 19, 2010 7:24 AM
Mackenzie said...
PhotoHand:
Well then let the geeks have our shiny new toy! Geeks are a perfectly valid niche.
June 19, 2010 8:00 AM
jarko_ said...
This is great. Not only because I find it useful but also for the blind people.
June 19, 2010 8:02 AM
NicolasJEngler said...
Cool, geeky, and practical.
June 19, 2010 8:07 AM
Jasper Winkel said...
Wish I could do this in windows. =P
June 19, 2010 8:53 AM
JuanJo said...
btw in an ubuntu lucid, trying to do "google docs edit ..." will give you
"Editing documents is not supported for gdata-python-client < 2.0"
This is because ubuntu repos only provide python-gdata 1.2.4, but you can upgrade it by downloading and installing debian squeeze .deb package with:
$ wget https://ftp.ch.debian.org/debian/pool/main/p/python-gdata/python-gdata_2.0.8-1.1_all.deb
$ sudo dpkg -i python-gdata_2.0.8-1.1_all.deb
June 19, 2010 10:01 AM
sojourner712 said...
Cool!
June 19, 2010 11:03 AM
sojourner712 said...
Cool!
June 19, 2010 11:06 AM
shj said...
This is very nice, but it would be much more useful to me, if GoogleCL could use a different character set than UTF-8.
June 19, 2010 11:11 AM
Tor Nilsen said...
Works fine under Mac OS X 10.6 with the system default python :)
^5 Google. :)
June 19, 2010 7:58 PM
yottzumm said...
How about a better name, like gsh gosh, gush, goosh, gython, guython, galthon, goothon. Or all those already taken?
June 19, 2010 11:21 PM
The said...
I've been typing to upload a video to youtube using this. It works on tiny test videos, but when I try it on the 395MB video I want to upload, I always get an error:
Loading DSCN0882.AVI
Traceback (most recent call last):
File "/usr/bin/google", line 448, in
main()
File "/usr/bin/google", line 442, in main
run_once(options, args)
File "/usr/bin/google", line 337, in run_once
task.run(client, options, args)
File "/usr/lib/pymodules/python2.6/googlecl/youtube/service.py", line 217, in _run_post
tags=options.tags, category=options.category)
File "/usr/lib/pymodules/python2.6/googlecl/youtube/service.py", line 129, in post_videos
self.InsertVideoEntry(video_entry, path)
File "/usr/lib/pymodules/python2.6/gdata/youtube/service.py", line 653, in InsertVideoEntry
raise YouTubeError(e.args[0])
gdata.youtube.service.YouTubeError: {'status': 401, 'body': 'Unknown authorization header', 'reason': 'Unauthorized'}
What gives?
June 19, 2010 11:41 PM
Werner said...
Well, that's really something!
How about uploading a whole folder to Google Web Space?
How about synchronising this folder with the corresponding one on the harddrive?
Is there an code?
June 19, 2010 11:55 PM
jecaestevez said...
Muy buena idea.
June 20, 2010 3:33 AM
Rasmus S said...
@Jake Kelly: you can still of course do e.g.
cat Desktop/post.txt | google blogger post --blog "helloes"
by the way, useless use of cat detected:
google blogger post --blog foo < Desktop/post.txt
June 20, 2010 4:19 AM
Phil Crump said...
This is just awesome. :-D
June 20, 2010 6:48 AM
Nicolas_Raoul said...
Sweet!
Are there plans to have this tool for tasks?
At least: list tasks, add a task, mark a taskas done... does not seem extremely hard to do.
June 20, 2010 10:24 PM
4v4l0n42 said...
This is so awesome.
June 21, 2010 12:48 AM
Mark R said...
Very very nice! Seems like the only company that can do real innovation, is Google.
Now if only we could get a google-plugin for {a,i}spell in LyX 2.0 ;)
June 21, 2010 1:27 AM
शंतनू said...
Is it possible to use xml.etree.cElementTree (python 2.5+) instead of ElementTree?
June 21, 2010 11:25 AM
Hunter said...
Another vote for google tasks please!
June 21, 2010 10:30 PM
XTL said...
It'd be great to get these to Debian and other repositories, but why not put them on the Google repos for a start?
June 22, 2010 6:15 AM
pat5star said...
Awesome! Exactly what I've wanted for awhile and this is also the push I've needed that will have me take another look at picasa to replace digikam with again. Thank you Google!
June 22, 2010 5:19 PM
Mrt said...
Cool! tnQ
June 23, 2010 2:37 AM
ankit anand said...
Keep growing Mates.. Awesome work.. Expected it to come some time back..
Still we need some improvement i guess...
June 23, 2010 10:18 PM
smyth_rj said...
sweet!! and I just spent a couple hours figuring out how to use wget to get my googledocs.
viva la google!!
June 24, 2010 4:02 PM
novi said...
Big step to avoid daily and repetive clickclick. Now I want a real shell at GAE.
June 26, 2010 4:16 PM
can said...
No love for the people behind a proxy :(
July 8, 2010 11:50 AM
Maxo said...
This is all full of win. I hope that Google Voice support comes very soon.
I'd love to be able to: google voice text 5555555555 "Win!"
July 16, 2010 8:53 PM
Pay said...
GOOGLE CL AND GMAIL:
How about using Google CL to command the functions of a Gmail box. Compose a Gmail, Send a Gmail, Reply to Gmail, Search Gmail. Sound interesting? Any time lines for availability?
July 20, 2010 10:50 PM
Kells said...
Did you know that GoogleCL has supported 6 Google services such as Blogger, Picasa Web, YouTube, Gmail Contact, Google Docs and Google Calendar?
August 4, 2010 6:50 PM
Post a Comment