How to get the network status (online/offline) and attribute it to a variable in shell script?
|
another one... for older NICs, the command mii-tool is awesome |
|||
|
|
|
If you use network manager for your network connection, you could query it via dbus somewhat like this:
(somewhat deprecated but still works, for newer interfaces you'd just query a different address) If that returns a "3" you are "connected" as described in http://projects.gnome.org/NetworkManager/developers/spec.html#type-NM_STATE (but it says nothing about internet connectivity). If you really wanna know whether you have internet connectivity, just ping a remote server like google.com and see if that worked or not. |
|||
|
|
|
I'm going to reccomend
(The ninth column is the state of the interface) |
|||||||
|
|
You say you simply want the online/offline status of an interface, and aren't concerned with speed or link-type. Try ethtool, as root:
|
||||
|
|
