-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.sh
More file actions
executable file
·40 lines (29 loc) · 978 Bytes
/
get.sh
File metadata and controls
executable file
·40 lines (29 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# warning: this will download ~100GB on to your machine
# see this https://urs.earthdata.nasa.gov/documentation/for_users/data_access/curl_and_wget
# should have this entry in ~/.netrc:
# machine urs.earthdata.nasa.gov
# login <username>
# password <password>
total=$(wc -l < srtm30m_urls.txt)
count=0
MAX_JOBS=300 # max concurrent downloads
# function to count background jobs
function wait_for_jobs() {
while (( $(jobs -rp | wc -l) >= MAX_JOBS )); do
sleep 1
done
}
touch ~/.urs_cookies
while IFS= read -r url || [[ -n "$url" ]]; do
wait_for_jobs # wait if max jobs running
wget -q --load-cookies ~/.urs_cookies --save-cookies ~/.urs_cookies --keep-session-cookies "$url" &
((count++))
# Print progress on the same line
printf "\rProgress: %4d / %d URLs downloaded" "$count" "$total"
if (( count % 100 == 0 )); then
sleep 5
fi
done < srtm30m_urls.txt
wait # wait for all background jobs to finish
echo -e "\nDone!"