Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Dropbox/Google Docs/LaTeX Instructions

Dropbox + Google Docs + LaTeX

Getting Dropbox

For headless Linux servers you can install a copy of Dropbox in your home folder using the following command:


cd ~ && wget -O - "" | tar xzf -


cd ~ && wget -O - "" | tar xzf -

Then start dropbox:


It will give you a URL to go to provide that machine with an access token.

(described here as well:

If it's not already available on your system, you will also need to control your dropbox instance. Make sure the file is flagged executable after you download it (chmod +x and put it somewhere in your path.

Uploading Documents to Google Docs

If you don't already have them, you will need an install of GoogleCL and gdata <=2.0.14. As of the time this was written, 2.0.15 & 2.0.16 were causing issues with googlecl and docs. If these are packaged for your system and gdata is 2.0.14 or a bit earlier, go ahead and use those.

*NOTE: Based on the discussion linked above, it may now be possible to use a *trunk version of googlecl with the latest gdata, but I haven't tested this.

Get files that you want to start with somewhere on the machine with GoogleCL & gdata and upload them (switch to the directory containing the .tex files you wish to upload):

google docs upload --folder=<foldername> --format=txt *.tex

where foldername is the collection name you want on google docs. Make sure that you have created this collection first or the files will go into your main collection.

If you also have other files you want editable as text files you can follow the same formula above (e.g.: for bib files):

google docs upload --folder=<foldername> --format=txt references.bib

The googlecl client will probably ask you to authorize use with your account in the process by giving you a link (maybe opening chrome over X11) and you'll have to paste back a token into the command line that is provided after you give permission on the site. If it opens something like lynx you may have connected to a machine over SSH without X11 forwarding or your default browser might be set to a text-based one. It appears that things won't work over lynx/links so you may need to enable X11 forwarding to allow it to open a browser in the background (add -X to your ssh command line to enable this when you connect to the host that Dropbox will be running on).

Document Build Script

Now modify the variables at the top of the script below so that the paths and names are correct and put this somewhere in your directory and chmod +x the file (I put it in ~/bin), making sure that you've set up the destination directory in Dropbox (mkdir -p ~/Dropbox/<path to folder to download/build in>):


# name of output pdf file

# subfolder in dropbox for builds

# path to where is installed

# folder name on google docs

if [ ! -f $OUTPUT_PDF ] || [ ! -f "delete_to_refresh" ]
 google docs get --folder=$DOCS_FOLDER --format=txt .
 for file in *.txt
   sed -i 's/\xe2\x80\x9c/\`\`/g' "$file"
   sed -i 's/\xe2\x80\x9d/\x27\x27/g' "$file"
   sed -i 's/\xe2\x80\x98/\`/g' "$file"
   sed -i 's/\xe2\x80\x99/\x27/g' "$file"
   iconv -f utf8 -t ascii -c "$file" | sponge "$file"
 rename 's/\.txt$//' *.txt -f
 touch delete_to_refresh

NOTE: In the version above, the sponge command is used which can be found in the moreutils package (available in Ubuntu and RHEL/Fedora).


apt-get install moreutils


yum install moreutils

Make sure that all the other dependencies other than the .tex files are in the appropriate path structure around the destination directory, and also put a Makefile in the destination with a default rule that builds the pdf named in the script.

Test that the script works by running it.

Now add this to your crontab (crontab editor can be invoked using: crontab -e):

*  *  *   *   *     /home/<username>/bin/<scriptname>

If you also want to prevent it from sending email every time it runs, you can add the following line:


Now you can go to dropbox & google docs and share the folder and collection as needed. When you delete the named PDF from the build directory or the "delete_to_refresh" file, it should attempt to update the build the next time the cron job runs.


This comment has been minimized.

Copy link

@errordeveloper errordeveloper commented Aug 15, 2012


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.