Debian Codegraph @

misc/getxmlobs

raw symbols SCIP
1 #!/bin/sh
2 #
3 BASE_URL="http://www.weather.gov/xml/current_obs"
4
5 usage () {
6 echo "Usage: $0 <station> [ <station> ... ]"
7 exit 1
8 }
9
10 date=`date -u '+%y%m%d'`
11 hour=`date -u '+%H'`
12
13 stations=""
14 while [ "$#" -gt 0 ]; do
15 case $1 in
16 -*)
17 echo "unrecognized option: $1"
18 usage;;
19 [A-Z][A-Z0-9][A-Z0-9][A-Z0-9])
20 stations="$stations $1"
21 shift;;
22 esac
23 done
24
25 if [ -z "$stations" ]; then
26 usage
27 fi
28
29 for name in $stations; do
30 file="$name-${date}-${hour}Z.xml"
31 echo "Downloading observations for station $name into $file"
32 curl -s -S -R "$BASE_URL/${name}.xml" -o "$file"
33 done
34