View Single Post
Benson's Avatar
Posts: 4,930 | Thanked: 2,272 times | Joined on Oct 2007
#3
Originally Posted by brendan View Post
/sbin/ifconfig wlan0

will give you an IP address, if you are connected. also, the RX/TX counters will not be 0. you should not need root access for this.
Don't know what exact result you're after; if you want to use it in a shell conditional, grep it for UP, like this for wlan0:
Code:
if [ "x`/sbin/ifconfig wlan0 |grep UP`" != x ] ; then
  echo 'Connection'
else
  echo 'No connection'
fi
I don't know what interface BT connections show up as; but something like (if it were bt0):
Code:
if [ "x`/sbin/ifconfig wlan0 |grep UP`" != x ] || [ "x`/sbin/ifconfig bt0 |grep UP`" != x ] ; then
  echo 'Connection'
else
  echo 'No connection'
fi
 

The Following User Says Thank You to Benson For This Useful Post: