Skip to content

Instantly share code, notes, and snippets.

@kevinbird61
Created May 17, 2019 11:51
Show Gist options
  • Save kevinbird61/029c7009807a2d9dc6ccd1d8b5c00e6a to your computer and use it in GitHub Desktop.
Save kevinbird61/029c7009807a2d9dc6ccd1d8b5c00e6a to your computer and use it in GitHub Desktop.
Download from remote host.
#!/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
@kevinbird61
Copy link
Author

can add --no-check-certificate after wget to avoid some problem cause by libssl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment