Linux script to upload files to DropBox and Google drive; send email when there is a new file
1. Linux script to upload file
Dropbox
See hereGoogle drive
Ref: https://gist.github.com/deanet/3427090You have to update the username and password, and the folderId.
folderId can be found from Google Drive URL in your browser. For example, if the Google Drive folder to which you want to upload thing has the following URL:
https://drive.google.com/?tab=wo&authuser=0#folders/1234567890AB-CDEFGHIJKLMNOPQR
the folderId would be 1234567890AB-CDEFGHIJKLMNOPQR
Sample script
# Things to update
username="xxxx@gmail.com"
password="xxxx"
pewede="/tmp"
tipe="application/x-mobi"
folderId="xxxx"
OUTFILE2=myfile.mobi
accountype="GOOGLE" #gooApps = HOSTED , gmail=GOOGLE
det=`date +%F`
browser="Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1"
/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: $OUTFILE2" "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: $OUTFILE2" "$uploadlink" > $pewede/goolog.upload.txt
Comments
Post a Comment