* FIX: use 'tr' to replace repeated SPACE with a single SPACE before 'cut' lines
[lab.git] / iptables / setnapt.sh
index 6093f6d..5626c6c 100755 (executable)
@@ -30,7 +30,7 @@ fi
 sleep 60
 
 if [ -z "${GATEWAYS}" ]; then
-    GATEWAYS=`/sbin/ip route show table main | grep -w default | cut -d ' ' -f 5`
+    GATEWAYS=`/sbin/ip route show table main | grep -w default | tr -s ' ' | cut -d ' ' -f 5`
 fi
 
 for GW in ${GATEWAYS}; do
@@ -39,7 +39,7 @@ for GW in ${GATEWAYS}; do
         continue
     fi
     
-    IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | cut -d t -f 2 | cut -d ' ' -f 2 | cut -d / -f 1`
+    IPADDR=`/sbin/ip addr show dev ${GW} | grep -w inet | tr -s ' ' | cut -d ' ' -f 3 | cut -d / -f 1`
     if [ -z "${IPADDR}" ]; then
         # device doesn't seem to have an IP address
         continue