Now tests for the presence of the gw ip in checkgw.
authorFrancois Fleuret <francois@fleuret.org>
Fri, 11 Mar 2011 16:43:14 +0000 (17:43 +0100)
committerFrancois Fleuret <francois@fleuret.org>
Fri, 11 Mar 2011 16:43:14 +0000 (17:43 +0100)
bashrc

diff --git a/bashrc b/bashrc
index dbe21a4..3c4123e 100644 (file)
--- 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
 }
 
 ######################################################################