Cách sử dụng (ở đây mình đặt tên cho file script là uploadgdrive.sh)
sh uploadgdrive.sh file username password
#!/bin/sh det=`date +%F` file="$1" browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1" username="$2" password="$3" 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" > /tmp/login.txt token=`cat /tmp/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?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: $mime_type" -H "Slug: $file" "$uploadlink" > /tmp/goolog.upload.txt