From 6b0cade9e2c6dad36086287e4a14b210a65db975 Mon Sep 17 00:00:00 2001 From: foo Date: Tue, 7 Jan 2014 10:42:52 +0000 Subject: [PATCH] tidied comments; fixed checkdata() and added handling of nulls in json --- river_levels_ | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/river_levels_ b/river_levels_ index f53bf7b..f65b4ca 100755 --- a/river_levels_ +++ b/river_levels_ @@ -15,11 +15,8 @@ # Parameters: # # config -# autoconf -# suggest # #%# family=manual -#%# capabilities=autoconf suggest # Expects a config file to specify which stations to include in the data check and name the catchment # @@ -40,7 +37,7 @@ CACHE=/tmp/river_level_.dat checkdata () { if test `find "$CACHE" -mtime +1` then - curl -o $CACHE -Ss $URLBASE || exit 1 + curl -o $CACHE -Ss $urlbase || exit 1 fi } @@ -82,5 +79,5 @@ fi for STATION in $stations ; do curl -m 5 -sS $urlbase/$STATION | - perl -MJSON::PP -e '$id=shift(@ARGV); $d=decode_json(<>) or die; print "river_level_$id.value $d->{data}->{current}->{level}\n";' $STATION + perl -MJSON::PP -e '$id=shift(@ARGV); $d=decode_json(<>) or die "error decoding station $id"; print "river_level_$id.value ", $d->{data}->{current}->{level} || "U", "\n";' $STATION done