Skip to content

Instantly share code, notes, and snippets.

@rnwolf
Forked from ShawnHuang/google.sh
Created August 19, 2013 10:13

Revisions

  1. @ShawnHuang ShawnHuang revised this gist Aug 19, 2013. 1 changed file with 5 additions and 4 deletions.
    9 changes: 5 additions & 4 deletions google.sh
    Original file line number Diff line number Diff line change
    @@ -30,16 +30,16 @@ password=`cat credits.ini | grep password |cut -d \= -f 2`
    accountype="GOOGLE" #gooApps = HOSTED , gmail=GOOGLE
    mime_type=`file -b --mime-type $file`

    /usr/bin/curl \
    msg=$(/usr/bin/curl \
    -v \
    --data-urlencode Email=$username \
    --data-urlencode Passwd=$password \
    -d accountType=$accountype \
    -d service=writely \
    -d source=cURL \
    "https://www.google.com/accounts/ClientLogin" > login.txt
    "https://www.google.com/accounts/ClientLogin")

    token=`cat login.txt | grep Auth | cut -d \= -f 2`
    token=`echo "$msg" | grep Auth | cut -d \= -f 2`

    uploadlink=`/usr/bin/curl \
    -Sv \
    @@ -61,4 +61,5 @@ uploadlink=`/usr/bin/curl \
    -H "Authorization: GoogleLogin auth=${token}" \
    -H "GData-Version: 3.0" \
    -H "Content-Type: $mime_type" \
    -H "Slug: $file" "$uploadlink" > goolog.upload.txt
    -H "Slug: $file" "$uploadlink" \
    -D /dev/stdout
  2. @ShawnHuang ShawnHuang revised this gist Aug 19, 2013. 1 changed file with 62 additions and 20 deletions.
    82 changes: 62 additions & 20 deletions google.sh
    Original file line number Diff line number Diff line change
    @@ -1,22 +1,64 @@
    #!/bin/bash

    ## uploading to google
    ## rev: 22 Aug 2012 16:07

    det=`date +%F`
    if [ ! -f $1 ]
    then
    echo "please provide a file in arg"
    exit -1
    fi

    #assign folder to upload
    if [ -z "$2" ]
    then
    folderid="root"
    else
    folderid="$2"
    fi

    creditFile=credits.ini
    if [ ! -f $creditFile ]
    then
    echo "please fill $creditFile (file has just been created)"
    echo "username=$login
    password=$pass">$creditFile
    exit -1
    fi

    file="$1"
    browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1"
    username="[email protected]"
    password="password"
    accountype="HOSTED" #gooApps = HOSTED , gmail=GOOGLE
    pewede="/tmp"
    file="file-$det.tar"
    tipe="application/x-tar"

    /usr/bin/curl -v --data-urlencode Email=$username --data-urlencode Passwd=$password -d accountType=$accountype -d service=writely -d source=cURL "https://www.google.com/accounts/ClientLogin" > $pewede/login.txt

    token=`cat $pewede/login.txt | grep Auth | cut -d \= -f 2`


    uploadlink=`/usr/bin/curl -Sv -k --request POST -H "Content-Length: 0" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $tipe" -H "Slug: $file" "https://docs.google.com/feeds/upload/create-session/default/private/full?convert=false" -D /dev/stdout | grep "Location:" | sed s/"Location: "//`

    username=`cat credits.ini | grep username |cut -d \= -f 2`
    password=`cat credits.ini | grep password |cut -d \= -f 2`

    accountype="GOOGLE" #gooApps = HOSTED , gmail=GOOGLE
    mime_type=`file -b --mime-type $file`

    /usr/bin/curl \
    -v \
    --data-urlencode Email=$username \
    --data-urlencode Passwd=$password \
    -d accountType=$accountype \
    -d service=writely \
    -d source=cURL \
    "https://www.google.com/accounts/ClientLogin" > login.txt

    token=`cat login.txt | grep Auth | cut -d \= -f 2`

    uploadlink=`/usr/bin/curl \
    -Sv \
    -k \
    --request POST \
    -H "Content-Length: 0" \
    -H "Authorization: GoogleLogin auth=${token}" \
    -H "GData-Version: 3.0" \
    -H "Content-Type: $mime_type" \
    -H "Slug: $file" \
    "https://docs.google.com/feeds/upload/create-session/default/private/full/folder:$folderid/contents?convert=false" \
    -D /dev/stdout | grep "Location:" | sed s/"Location: "//`

    /usr/bin/curl -Sv -k --request POST --data-binary "@$file" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $tipe" -H "Slug: $file" "$uploadlink" > $pewede/goolog.upload.txt
    /usr/bin/curl \
    -Sv \
    -k \
    --request POST \
    --data-binary "@$file" \
    -H "Authorization: GoogleLogin auth=${token}" \
    -H "GData-Version: 3.0" \
    -H "Content-Type: $mime_type" \
    -H "Slug: $file" "$uploadlink" > goolog.upload.txt
  3. @deanet deanet created this gist Aug 22, 2012.
    22 changes: 22 additions & 0 deletions google.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,22 @@
    #!/bin/bash

    ## uploading to google
    ## rev: 22 Aug 2012 16:07

    det=`date +%F`
    browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1"
    username="[email protected]"
    password="password"
    accountype="HOSTED" #gooApps = HOSTED , gmail=GOOGLE
    pewede="/tmp"
    file="file-$det.tar"
    tipe="application/x-tar"

    /usr/bin/curl -v --data-urlencode Email=$username --data-urlencode Passwd=$password -d accountType=$accountype -d service=writely -d source=cURL "https://www.google.com/accounts/ClientLogin" > $pewede/login.txt

    token=`cat $pewede/login.txt | grep Auth | cut -d \= -f 2`


    uploadlink=`/usr/bin/curl -Sv -k --request POST -H "Content-Length: 0" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $tipe" -H "Slug: $file" "https://docs.google.com/feeds/upload/create-session/default/private/full?convert=false" -D /dev/stdout | grep "Location:" | sed s/"Location: "//`

    /usr/bin/curl -Sv -k --request POST --data-binary "@$file" -H "Authorization: GoogleLogin auth=${token}" -H "GData-Version: 3.0" -H "Content-Type: $tipe" -H "Slug: $file" "$uploadlink" > $pewede/goolog.upload.txt