From owner-freebsd-questions@FreeBSD.ORG Sat Sep 1 02:56:16 2007 Return-Path: Delivered-To: freebsd-questions@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A96716A419 for ; Sat, 1 Sep 2007 02:56:16 +0000 (UTC) (envelope-from Hinkie@paradise.net.nz) Received: from smtp3.clear.net.nz (smtp3.clear.net.nz [203.97.33.64]) by mx1.freebsd.org (Postfix) with ESMTP id C92FA13C481 for ; Sat, 1 Sep 2007 02:56:15 +0000 (UTC) (envelope-from Hinkie@paradise.net.nz) Received: from cheqsoftserver (203-97-234-182.cable.telstraclear.net [203.97.234.182]) by smtp3.clear.net.nz (CLEAR Net Mail) with SMTP id <0JNO002WY5HPUD10@smtp3.clear.net.nz> for freebsd-questions@FreeBSD.ORG; Sat, 01 Sep 2007 14:56:14 +1200 (NZST) Date: Sat, 01 Sep 2007 14:54:45 +1200 From: Hinkie To: Robert Huff , freebsd-questions@FreeBSD.ORG Message-id: <035201c7ec43$73dff6d0$1e00a8c0@cheqsoft.local> MIME-version: 1.0 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.3790.2929 X-Mailer: Microsoft Outlook Express 6.00.3790.2929 Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: 7bit X-Priority: 3 X-MSMail-priority: Normal References: <033a01c7ec3a$ea145d90$1e00a8c0@cheqsoft.local> <18136.53821.270032.59301@jerusalem.litteratus.org> Cc: Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Sep 2007 02:56:16 -0000 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" To: "Hinkie" 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