On Wed, 26 Jul 2000, Marcus Meissner wrote:

> On Tue, Jul 25, 2000 at 10:14:25AM -0500, Aric Stewart wrote:
[...]
> How to check network connections:
> 
> Parse output of:
>       /sbin/ifconfig  - for occurences of ppp*, eth* or similar.
>                       - for occurences of non 127.* addresses.

    You may have these on a non-connected lan.

>       /sbin/route -n  - dito

    Maybe the method that has the most chances of returning the correct
result would be to look for a default route in the output of 'route'.  I
think the way to recognize it is to look for: 
 - a genmask of 0.0.0.0 
 - check that the Flags contain 'U'

    I don't know how portable this is. 'route' may return things in a
different format on Solaris for instance. In particular I've seen
Solaris machines for which 'route' returns nothing and yet they have a
functional internet access. I'm still puzzled by this one. 
    On Linux you can also parse /proc/net/route, not that it's more
portable, but it saves the creation of a process. 



--
Francois Gouget         [EMAIL PROTECTED]        http://fgouget.free.fr/
      Any sufficiently advanced bug is indistinguishable from a feature.
                            -- from some indian guy

Reply via email to