Date: Sat, 01 Sep 2007 14:54:45 +1200 From: Hinkie <Hinkie@paradise.net.nz> To: Robert Huff <roberthuff@rcn.com>, freebsd-questions@FreeBSD.ORG Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up) Message-ID: <035201c7ec43$73dff6d0$1e00a8c0@cheqsoft.local> References: <033a01c7ec3a$ea145d90$1e00a8c0@cheqsoft.local> <18136.53821.270032.59301@jerusalem.litteratus.org>
next in thread | previous in thread | raw e-mail | index | archive | help
Wow, thats Kewl!
Thanks Robert, yes, that makes the code a little more portable!
In a similar vein, to make it truly run, and for being so good(!), how do I automate getting the WAN interface name (em0 dc0 etc) on
different machines!?
Kind regards
David Hingston
----- Original Message -----
From: "Robert Huff" <roberthuff@rcn.com>
To: "Hinkie" <Hinkie@paradise.net.nz>
Sent: Saturday, September 01, 2007 2:45 PM
Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up)
Hello:
> from edit.php create / write into new file /usr/bin/pinger.sh
#!/bin/sh
ping -c1 Insert_1st_Gateway_Hop_Here_commonly_Static_IP_a.b.c.1
if [ $? -eq 2 ]; then
ifconfig em0 down
ifconfig em0 up
echo 'Gateway Down'
else
echo 'Gateway Up'
fi
And you might consider replacing:
ping -c1 Insert_1st_Gateway_Hop_Here_commonly_Static_IP_a.b.c.1
with:
ping -c1 `netstat -rn | head -n 5 | tail -n 1 | awk '{ print $2 }'`
Robert Huff
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?035201c7ec43$73dff6d0$1e00a8c0>
