fetch.sh - randomcrap - random crap programs of varying quality
(HTM) git clone git://git.codemadness.org/randomcrap
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
fetch.sh (754B)
---
1 #!/bin/sh
2
3 # curl settings:
4 # - follow redirects (max 3), default was 50.
5 # - specify connection timeout: 10 seconds.
6 # - specify maximum time for transfer: 5 minutes.
7 # - silent (no progressbar).
8 # - hide user-agent (curl version and OS).
9
10 # historical data (since ~1999):
11 # https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml?c111a883a13a4b7a9dfa160f65abde7c
12
13 filename="data.xml"
14 rm -f "$filename"
15 if ! curl -L --max-redirs 3 --connect-timeout 10 --max-time 300 \
16 -H 'User-Agent:' \
17 'https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml' -o "$filename"; then
18 echo "could not fetch currency cates from European Central Bank" >&2
19 exit 1
20 fi
21
22 if ! test -f "$filename"; then
23 echo "download failed: $filename not saved" >&2
24 exit 1
25 fi