diff options
author | Florian Steinel <fsteinel-git@github.com.flonet.net> | 2017-01-09 09:18:41 +0100 |
---|---|---|
committer | nutzer <you@domain.com> | 2017-01-09 09:18:41 +0100 |
commit | da5d1f7daeafae934ec2352e16c71b0314f52eb1 (patch) | |
tree | 4badb91c4ceb08bfcaf73e5d9e5b021f1ddab9b5 | |
parent | ecbaf760902a42482da0fb1c981b619c88326790 (diff) |
test for numeric value, echo error otherwise
-rw-r--r-- | numnodes.sh | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/numnodes.sh b/numnodes.sh index 8907720..29858b1 100644 --- a/numnodes.sh +++ b/numnodes.sh @@ -4,11 +4,17 @@ #echo -n "online nodes: " num=$(wget http://127.0.0.1:4000/metrics -qO - | grep meshnodes_online_total|cut -d ' ' -f2) 2> /dev/null -if test "$num" -ge 1; then - - num="$(expr $num - 4)" - cd "$(dirname "$0")" - - sed 's/<NUM_NODES>/'"$num"'/g' numnodes.template > _site/numnodes.html - -fi +case $num in + ''|*[!0-9]*) echo "bad number: >>$num<<" ;; + *) + if test "$num" -ge 1; then + + num="$(expr $num - 4)" + cd "$(dirname "$0")" + + sed 's/<NUM_NODES>/'"$num"'/g' numnodes.template > _site/numnodes.html + + fi + ;; +esac +# vim: syntax=bash ts=4 sw=4 sts=4 sr noet |