#!/bin/sh PING_SERVER="1.1.1.1" IF=$(route show default | grep interface | awk "{print \$2 }") IP=$(ifconfig $IF | grep inet | awk "{ print \$2 }") PING=$(ping -c 1 -t 5 $PING_SERVER | awk "BEGIN { RS = \"[\t ]*\" } /^time=/ { sub(/^time=/, \"\"); print \$0; } { next; }") if [ "$IF" = "wlan0" ] then SSID=$(ifconfig wlan0 | grep ssid | awk "{ sub(/^[^\"]*/, \"\"); sub(/[^\"]*\$/, \"\"); print \$0; }") fi if [ "$PING" = "" ] then ONLINE="OFFLINE" else ONLINE="ONLINE ($PING)" fi echo "$IF $IP $ONLINE $SSID" if [ "$ONLINE" = "OFFLINE" ] then echo "" echo \#FF0000 else echo "" echo \#00FF00 fi