Code: Select all
#!/bin/sh
# Test for network conection without ping
# adapted from https://bbs.archlinux.org/viewtopic.php?id=55485
#
for interface in $(ls /sys/class/net/ | grep -v lo);
do
if [[ $(cat /sys/class/net/$interface/carrier) = 1 ]]; then
OnLine="Online"
elif [[ $(cat /sys/class/net/$interface/carrier) = 0 ]]; then
OnLine="Not Online"
fi
done
export OnLine
echo "$OnLine"
yad --text="$OnLine" --timeout=1