[svlug] Test for network up in a shell script?

Hans van Rietschote hans at mercuryswan.com
Wed Dec 1 09:50:53 PST 2010


I find fping does a great job. Just fping av.com if is is pingable your
network is up

if fping -q av.com
then
   echo "network up"
else
   echo "network down"
fi

Hans


On Wed, Dec 1, 2010 at 12:32 AM, Daniel Pittman <daniel at rimspace.net> wrote:

> conover at rahul.net (John Conover) writes:
>
> > Is there a way of testing to see if the network is up and running from a
> > shell script?
>
> Not trivially, no.  So, you can try to solve this a bunch of ways, none of
> which are absolutely reliable or portable.
>
> If your system has Network Manager installed, the nm-cli tool has a bunch
> of
> reporting capabilities - or you can subscribe to the DBus notifications.
> Those give you reasonable information[1] for systems with NM installed and
> used.
>
> Otherwise, your best option is to troll the output of /sbin/ip (or ifconfig
> and route) to see if there are any interesting looking interfaces up and
> with a suitable default route installed.
>
>        Daniel
>
> Footnotes:
> [1]  ...and qdbus is a nice way to interact with it from a shell script;
> that
>     is part of KDE, I think.
>
> --
> ✣ Daniel Pittman            ✉ daniel at rimspace.net            ☎ +61 401 155
> 707
>               ♽ made with 100 percent post-consumer electrons
>
> _______________________________________________
> svlug mailing list
> svlug at lists.svlug.org
> http://lists.svlug.org/lists/listinfo/svlug
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.svlug.org/archives/svlug/attachments/20101201/072620d8/attachment.htm


More information about the svlug mailing list