Question

I´m trying to make a collection of scripts in php and bash that ask to bugsense for the errors in my app, make everything what I need and upload a couple of files to Google Docs so everyone in the company can see all the data up to date.

I do this because, as you know, Bugsense just gives me information of the last 30 days so I cannot store there a historical of my applications crashes.

The only problem that I´m having is how to edit a Google Spreadsheet without deleting it and uploading again. I mean, what I´m doing right now is:

google docs get $GOOGLE_DOC $GOOGLE_DOC_TSV

Now that I have the file I want to edit, I delete it from my drive because if I upload again it will not override and I will have to files with the same name:

google docs delete $GOOGLE_DOC --yes

After that I just do everything what I need with file and upload it again:

google docs upload $GOOGLE_DOC_TSV

The problem with this is that I´m having a new file everytime the script is runned so I cannot share that document because I´m deleting it everytime and uploading a new one.

The other thing that googlecl allows is to edit a file:

google docs edit $GOOGLE_DOC --format tsv --editor vim

But with this, the proccess is not automatic because you need to deal with vim. I´ve been checking everywhere about it but nothing found that solves my problem.

Was it helpful?

Solution

Finally I found how to do it looking to Python code of googlecl. What you need is to build a script that do the following:

#!/bin/bash -l
#$ -S /bin/bash
#S -N $1
export GOOGLE_DOC=$1
#!Then do whahever you need to do with the google file

This script is just taking the value of the first argument (which will be the path to the google doc that you want to edit by doing whatever with it). Then all what you need is to call to googlecl like this:

google docs edit --title GOOGLE_DOC_TITLE --format FORMAT --editor SCRIPT_WE_JUST_BUILD

GoogleCl is creating a temporary file in your system and is passing to the editor(our script) the path to that temporary file. So what we are getting is the path to the temporary file.

Whenever yoy finish googlecl will look if there is any change in that file and will upload it if YES.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top