Skip to content

Instantly share code, notes, and snippets.

@lopnor
Created January 3, 2010 08:23
Show Gist options
  • Select an option

  • Save lopnor/267883 to your computer and use it in GitHub Desktop.

Select an option

Save lopnor/267883 to your computer and use it in GitHub Desktop.
#!/bin/sh
MAIL=$1
PASS=$2
TITLE=$3
if [ -z "$MAIL" -o -z "$PASS" -o "$TITLE" ]
then
echo "usage: $0 'your.account@gmail.com' 'your_password' 'filename'"
exit 1
fi
auth=`\
wget \
-q \
--post-data="Email=$MAIL&Passwd=$PASS&service=writely" \
-O - \
'https://www.google.com/accounts/ClientLogin'|
egrep '^Auth='|
cut \
-d'=' \
-f2`
docurl='https://docs.google.com/feeds/default/private/full/?title=$TITLE&title-exact=true'
url=`\
wget \
-q \
--header="Authorization: GoogleLogin auth=\"$auth\"" \
--header="Gdata-Version: 3.0" \
-O - \
$docurl \
perl \
-e '<> =~ m/<content .+?src=\x27([^>]+)\x27\/>/ and print $1'`
echo "the document url is $url" >&2;
got=`\
wget \
-q \
--header="Authorization: GoogleLogin auth=\"$auth\"" \
--header="Gdata-Version: 3.0" \
-O - \
$url`
echo $got;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment