Question: How to get the network status (online/offline) and attribute it to a variable in shell script?

Answer: 
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:

```
dbus-send --type=method_call --print-reply --system --dest="org.freedesktop.NetworkManager" "/org/freedesktop/NetworkManager" org.freedesktop.NetworkManager.state

```

(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 want to know whether you have internet connectivity, just ping a remote server like google.com and see if that worked or not.