Friday, June 18, 2010

Installing Google Command-Line Tool for Linux

Ever wanted to upload a folder full of photos to Picasa from a command prompt?' Google introduced today a new project, Google CL, that lets you do that and much more. It's a new command line tool for Linux that acts as an interface with Google services; you can upload videos to YouTube or maybe post a new blog post in Blogger in just one line


Installing Google CL:

DEPENDENCIES

GoogleCL requires Python 2.5 or 2.6 and the gdata python client library. You can get the library from the project homepage: http://code.google.com/p/gdata-python-client/

1. Download gdata-2.0.10.tar.gz or .zip
2. extract the source tar zxvf gdata-2.0.10.tar.gz
3. cd gdata-2.0.10
4. Run sudo ./setup.py install

I got this error...

/usr/lib/python2.6/distutils/dist.py:266: UserWarning: Unknown distribution option: 'install_requires'
warnings.warn(msg)
running install
error: invalid Python installation: unable to open /usr/lib/python2.6/config/Makefile (No such file or directory)

In case of above error install python-setuptools-devel which will also install python-devel as dependency,

sudo yum install python-setuptools-devel

and do the step (4) again

Running Tests and Samples

./tests/run_data_tests.py

If this script runs correctly, you should see output on the command line like this:

Running all tests in module gdata_test
.....................
----------------------------------------------------------------------
Ran 21 tests in 0.028s

OK

Running all tests in module atom_test
...............................................
----------------------------------------------------------------------
Ran 47 tests in 0.038s

OK

....

Finally get the Google CL source from http://code.google.com/p/googlecl/

1. Extract the source
tar xvf googlecl-0.9.5.tar.gz

2. change to googlecl-0.9.5 directory and run
sudo python setup.py install

Now you are ready to play with Google CL and starting posting blogs, videos to youtube etc right from your Linux command Line,

One first run for every google service you will get ...

Did not find config / preferences file at /home/myhome/.googlecl/config
... making new one.
Please specify user: myusername
(Hint: You can automatically launch your browser by adding "auth_browser = " to your config file under the GENERAL section, or define the BROWSER environment variable.)
Please log in and/or grant access via your browser at https://www.google.com/accounts/OAuthAuthorizeToken?oauth_token=4%2FglE62XHHpOLmP6jhGGZumt6Tm2re then hit enter.


Specify the username and put the following in the ~/yourhome/.googlecl/config GENERAL section.

auth_browser = firefox

And when browser open Auth Token page click "Grant Acces"

Examples:

1. Post a blog
$ google blogger post --tags "GoogleCL, awesome" --title "Test Post" "I'm posting from the command line"

2. To post a blog from .txt file

$ google blogger post ~/Desktop/googlecl.txt

3. To delete a post
google blogger delete --title "Test Post"
Are you SURE you want to delete post "Test Post"? (y/N): y

For detail examples refer to GooglCL project web

No comments:

Post a Comment