/ Published in: Other
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
One that checks if there is a default gateway and if so pings it and displays both the gateway and the response time: Code: shopt -s extglob GW=$(netstat -rn|grep ^default|awk '{print $2}') if [[ ! $GW == +([[:digit:]]).+([[:digit:]]).+([[:digit:]]).+([[:digit:]]) ]]; then echo "no default gateway" exit 1 fi IFS='' PING=`ping -c1 -n -t5 -o $GW` RC=$? if [ $RC -eq 2 ]; then echo "gateway ($GW) no reply" exit 1 fi RT=$( echo $PING | head -n2 | tail -n1 | awk -F= '{print $4}' ) echo "gateway ($GW) $RT" exit $RC
URL: http://projects.tynsoe.org/phpBB2/viewtopic.php?p=745