

Introducing Google Command line Tool - dreur
http://google-opensource.blogspot.com/2010/06/introducing-google-command-line-tool.html

======
10ren
I use this to check my gmail from the command line (they don't include gmail
in the examples). Ugly but fun:

    
    
        alias gm1='curl -u USERNAME:PASSWORD --silent "https://mail.google.com/mail/feed/atom" |
        tr -d '\''\n'\'' |
        awk -F '\''<entry>'\'' '\''{for (i=2; i<=NF; i++) {print $i}}'\'' |
        sed -n "s/<title>\(.*\)<\/title.*name>\(.*\)<\/name>.*/\2 - \1/p" |
        sed '\''s/&lt;/>/g'\'' '
    

_EDIT_ and send mail by setting the headers (including _MAIL FROM:
<USERNAME@gmail.com>_) and body (using _uuencode_ for attachments) in _email_
, and then:

    
    
        echo "$email" | netcat ISPs_MAILSERVER 25

~~~
surki
I use wget for the same. I usually call it from gnu screen, to update the
status line with the no. of unread mails

    
    
      unread="$(wget --secure-protocol=TLSv1 --timeout=3 -t 1 -q -O - \
      https://${gmail_login}:${gmail_password}@mail.google.com/mail/feed/atom |
      sed -n "s/<fullcount>\(.*\)<\/fullcount>/\1/p")"
    
      unread=${unread:-0}
    
      echo $unread
    

And also worth checking out <http://groups.google.com/group/emacs-g-
client?pli=1> if you are into emacs side of the things.

------
btbytes
Quick recipe to make a blog post from the command line.

    
    
        $ cat - > newblogpost.txt
        type in what you have to say
        ^D
    

Use pandoc to convert the text bits to html bits

    
    
        $ pandoc newblogpost.txt -f markdown -t html -o newblogpost.html --no-wrap
    

Upload the transformed bits to blogger using the Google Command Line tool.

    
    
        $ google blogger post --title "Hello, world!" newblogpost.html
    

And you are done!

You can see the result here: [http://btbytes.blogspot.com/2010/06/how-to-make-
quick-blogpo...](http://btbytes.blogspot.com/2010/06/how-to-make-quick-
blogpost-to-blogger_6658.html)

~~~
spicyj
Just a heads-up: I think you can leave off the dash like so:

    
    
        $ cat > newblogpost.txt

------
sammyo
Quite cool but there isn't there just one rather obvious google service that
is missing. Nudge nudge, wink wink? Wouldn't it be handy to run an internet
wide grep with all the various search arguments and a nice filterable output?

~~~
olefoo
Google Grep would be awesome, but Google Find would be more useful, especially
if were augmented with a rich and extensible set of semantic switches.

    
    
       google find .org -type domain -owner "Gawker Media" -pagerank ">4" > ndenton.orgs.list
    

Would, for instance, find all .org domains registered by gawker media with a
pagerank greater than 4.

------
adulau
The Google Command Line Tool is interesting but it's missing the search (is
that intentional from Google? I don't know). I made a quick and dirty one
liner replace foo by your search query:

    
    
      curl -s "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&start=0&rsz=large&q=foo" | sed -e 's/[{}]/''/g' | awk '{n=split($0,s,","); for (i=1; i<=n; i++) print s[i]}' | grep -E "("url"|"titleNoFormatting")" | sed -e s/\"//g | cut -d: -f2- 
    

My notes about : [http://www.foo.be/cgi-
bin/wiki.pl/2010-06-19_Searching_Googl...](http://www.foo.be/cgi-
bin/wiki.pl/2010-06-19_Searching_Google_From_The_Command_Line)

------
Ixiaus
Emacs org-mode + Google Calendar... Here I come!

~~~
mark_h
There's gcal support already in emacspeak (Raman is a google employee):
[http://emacspeak.googlecode.com/svn/trunk/lisp/g-client/gcal...](http://emacspeak.googlecode.com/svn/trunk/lisp/g-client/gcal.el)
<http://bc.tech.coop/blog/070306.html>

------
sublemonic
Looks like gmail is in the works:
<http://code.google.com/p/googlecl/issues/detail?id=37#c0>

~~~
yellowbkpk
That one's specific to tasks. Here's one for mail itself:
<http://code.google.com/p/googlecl/issues/detail?id=43>

------
telemachos

        $ google docs edit --title "Shopping list" --editor vim
    

You had me at hello. Too pretty.

Also, and slightly off-topic: I cannot say how much I love Homebrew + Github.
I was halfway into writing a new formula for this, when I decided to check.
Sure enough, there's already a formula to install. Actually, I think two
people already submitted formulas. In any case, if you use Homebrew, you can
install it now.

~~~
telemachos
A quick update here: the googlecl package has been removed from Homebrew. The
recommendation is now to install it via pip (which is available from
Homebrew). Just in case someone sees this and wonders.

~~~
ra
Thanks! I was scratching my head there for a minute.

EDIT: The pypi package is "googlecl"

------
cmatthias
This is a nice little utility. It'd be good if it supported more google
services (reader, gmail?) but hopefully they'll add to it as time goes on.

~~~
samdk
It'd be nice, but I wouldn't count on it happening too soon: the necessary
APIs don't seem to exist.

It's based on the _gdata-python-client_ library
(<http://code.google.com/p/gdata-python-client/>) for accessing Google Data
APIs, and the complete list of them
(<http://code.google.com/apis/gdata/docs/directory.html>) doesn't include
Gmail/reader. It _does_ include a bunch of things that this doesn't support
yet though.

~~~
askedrelic
I've put a bit of work into a python library for Google Reader:
<http://github.com/askedrelic/libgreader>

There is another Perl library on github that supports pretty much everything
Reader does.

The Reader API has unofficially existed for awhile, but they don't seem to
mind you using it. They just added OAuth support a few months ago as well.

------
snprbob86
I really love how the sub-command names work with the script name to mirror
the full names of the Google products. Google's "Google Foo" naming scheme was
mandated from the top and was a good call for sooo many reasons (legal,
marketing, etc.) which now includes "makes for an awesome command line tool".

------
J_McQuade
Makes me wonder how many other web services could offer useful amounts of
their (usually unintuitive (for non-web programmers)) API's functionality with
a simple, unixy, command-line tool. This is going to save fans of scripting
languages a whole lot of doc-crawling.

~~~
spicyj
I have a feeling that normal people don't dream of having "simple" and "unixy"
in the same sentence.

~~~
yellowbkpk
I have a feeling that normal people don't care about a website's API unless
they also care (or at least use) command line tools.

------
moxiemk1
Clean living and good apis in your products makes writing awesome little apps
like this not to hard... which makes life good for all of us.

This has me pretty psyched, honestly. The scripting possibilities are
tantalizing.

~~~
InclinedPlane
One big cost of poor architecture and design is that you miss out on a lot of
serendipity. When every new use case comes at the cost of a long, hard slog
uphill over a mountain of design and implementation defects you choose your
destinations carefully, so you miss out on a lot of potential wins (both big
and small) just because you don't have the data to justify the changes.

------
telemachos
I just thought of another use for this. I've been using takspaper.vim and git
to manage a todo list with TaskPaper-like syntax, but without the overhead of
an application devoted _just_ to a todo list. (I feel about programs the way
Alton Brown does about cooking tools: use as few unitaskers as possible.)

This will make that a lot, lot easier and more automatic.

If you use Vim, see here for the taskpaper.vim syntax script:
<http://www.vim.org/scripts/script.php?script_id=2027>

------
d0m
outch, I think I'll soon be ready to say bye bye to my own little todo
application in command line. However, there are still some details that I will
miss by switching to google calendar :(

------
lowkey
That's cute, but Goosh (www.goosh.org) is better. I'm not affiliated with
goosh, just a fan. Check it out!

~~~
travisp
Goosh is neat, but isn't it actually browser-oriented (i.e. doesn't actually
work in your command line)? Also, they cover completely different services
(AFAIK). For example, Goosh does search and gmail. GoogleCL does picasa,
blogger, post youtube videos, docs, contacts, and calendar.

------
growt
this was my take on command line google _search_ with perl:
[http://stefan.grothkopp.com/googlepl-command-line-google-
sea...](http://stefan.grothkopp.com/googlepl-command-line-google-search-in-a-
shel)

------
K3G
This is wonderful! At what point will it be ported to OSX?

~~~
asenchi
Update your homebrew and: 'brew install googlecl'

~~~
dlib
Thanks, it works like a charm

Now I can easily hook up my scanner to my Google Docs

------
xenonite
should be named GoogleCLI for Google Command Line Interface.

CL is reserved for OpenCL, the Open Computing Language.

~~~
muuh-gnu
It was kinda used by OpenCL, to actually "reserve" something takes a lot more
work. And even then I would suppose that the abbrev CL was reserved by Common
Lisp during the last 25 years.

~~~
studer
To add to that list: Changelist. Chile TLD. Microsoft's C compiler (which is
roughly as old as Common Lisp). IBM's Control Language. And probably a whole
bunch of other things.

And this isn't a CLI, of course. In this case, that would be the shell itself.

------
morbidkk
have to figure out using this can one get daily digest of all google services
one is using

