Re: Checking if the network is up
> Hi,
> I am trying to write a script to use popclient to download the mail from
> the office's server. This will run on a portable. I want the script to
> check whether the network is up before attempting to retrieve any mail,
> as I am likely to use the notebook in other places and won't be hooked
> to the network.
>
> The question is:
>
> Is there any way of checking whether the network is responding so that I
> only run popclient when it is?
Yes, there are probably a number of ways.
You could check the output of netstat -r for a default route (something
like
"[ `netstat -rn | grep '^0\.0\.0\.0' | wc --lines` = 0 ] ||
popclient...", although there is probably an easier way to do that)
I have set it up so that on my system, bringing up my PPP connection
automatically creates a "/var/lock/ip-is-up", and bringing it down
deletes that file. Since I only have a single net connection, this
works. For multiple net connetions, some modification might have to be
done.
There are probably others, but I don't know them offhand.
One final note: I don't use a lap-top, but my computer is also not
connected to the internet fulltime. However, I run two popclients
every 5 minutes via a cron entry. I've decided that I don't need to
have then even check for the net connection first. Since popclient
aborts very quickly when it can't establish a connection, I don't even
notice that i have them running. Will this not work for you, too?
>
> Thanks.
> Luis.
>
--
Buddha Buck bmbuck@acsu.buffalo.edu
"She was infatuated with their male prostitutes, whose members were
like those of donkeys and whose seed came in floods like that of
stallions." -- Ezekiel 23:20
Reply to: