diff --git a/frontend/device/generic/device.lua b/frontend/device/generic/device.lua index 352d181e9..4915e444c 100644 --- a/frontend/device/generic/device.lua +++ b/frontend/device/generic/device.lua @@ -314,9 +314,9 @@ function Device:retrieveNetworkInfo() -- NOTE: No -w flag available in the old busybox build used on Legacy Kindles... local pingok if self:isKindle() and self:hasKeyboard() then - pingok = os.execute("ping -q -c 2 `ip r | grep default | cut -d ' ' -f 3` > /dev/null") + pingok = os.execute("ping -q -c 2 `ip r | grep default | tail -n 1 | cut -d ' ' -f 3` > /dev/null") else - pingok = os.execute("ping -q -w 3 -c 2 `ip r | grep default | cut -d ' ' -f 3` > /dev/null") + pingok = os.execute("ping -q -w 3 -c 2 `ip r | grep default | tail -n 1 | cut -d ' ' -f 3` > /dev/null") end if pingok == 0 then result = result .. "Gateway ping successful" diff --git a/frontend/ui/network/manager.lua b/frontend/ui/network/manager.lua index 5c3c7301a..9cb91cc25 100644 --- a/frontend/ui/network/manager.lua +++ b/frontend/ui/network/manager.lua @@ -104,9 +104,9 @@ function NetworkMgr:isConnected() -- `-c1` try only once; `-w2` wait 2 seconds -- NOTE: No -w flag available in the old busybox build used on Legacy Kindles... if Device:isKindle() and Device:hasKeyboard() then - return 0 == os.execute([[ping -c1 $(/sbin/route -n | awk '$4 == "UG" {print $2}')]]) + return 0 == os.execute([[ping -c1 $(/sbin/route -n | awk '$4 == "UG" {print $2}' | tail -n 1)]]) else - return 0 == os.execute([[ping -c1 -w2 $(/sbin/route -n | awk '$4 == "UG" {print $2}')]]) + return 0 == os.execute([[ping -c1 -w2 $(/sbin/route -n | awk '$4 == "UG" {print $2}' | tail -n 1)]]) end end end