Created
May 17, 2019 11:51
-
-
Save kevinbird61/029c7009807a2d9dc6ccd1d8b5c00e6a to your computer and use it in GitHub Desktop.
Download from remote host.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script for downloading file from remote server. | |
# Usage: ./download.sh gdrive <FILE_ID> <FILENAME> | |
function gdrive() | |
{ | |
CONFIRM=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate "https://docs.google.com/uc?export=download&id=$1" -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p') | |
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$CONFIRM&id=$1" -O $2 | |
rm -rf /tmp/cookies.txt | |
} | |
if [ $# -eq 0 ]; then | |
echo "Usage: $(basename $0) {gdrive}" | |
echo "\t./download.sh gdrive <FILE_ID> <FILENAME>" | |
exit | |
fi | |
if [ "$1" == "gdrive" ]; then | |
$1 $2 $3 | |
exit | |
fi | |
$1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can add
--no-check-certificate
afterwget
to avoid some problem cause by libssl.