From: Francois Fleuret Date: Fri, 11 Mar 2011 16:43:14 +0000 (+0100) Subject: Now tests for the presence of the gw ip in checkgw. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=04affe379943dc18a73e805fed5c318daf7cce01;p=scripts.git Now tests for the presence of the gw ip in checkgw. --- diff --git a/bashrc b/bashrc index dbe21a4..3c4123e 100644 --- a/bashrc +++ b/bashrc @@ -344,7 +344,13 @@ function netdown () { } function checkgw () { - ping $(route -n | grep ^0.0.0.0 | awk '{print $2}') + GW=$(route -n | grep ^0.0.0.0 | awk '{print $2}') + if [[ -n "${GW}" ]]; then + ping ${GW} + else + echo "Can not find a getaway." >&2 + return 1 + fi } ######################################################################