From owner-freebsd-questions@FreeBSD.ORG Wed Aug 29 20:18: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 5FD2716A417 for ; Wed, 29 Aug 2007 20:18:16 +0000 (UTC) (envelope-from Hinkie@paradise.net.nz) Received: from smtp5.clear.net.nz (smtp5.clear.net.nz [203.97.33.68]) by mx1.freebsd.org (Postfix) with ESMTP id 2A3EB13C478 for ; Wed, 29 Aug 2007 20:18:16 +0000 (UTC) (envelope-from Hinkie@paradise.net.nz) Received: from cheqsoftserver (203-97-234-182.cable.telstraclear.net [203.97.234.182]) by smtp5.clear.net.nz (CLEAR Net Mail) with SMTP id <0JNJ007BLXQE7340@smtp5.clear.net.nz> for freebsd-questions@FreeBSD.ORG; Thu, 30 Aug 2007 08:18:15 +1200 (NZST) Date: Thu, 30 Aug 2007 08:16:48 +1200 From: Hinkie To: Eric Crist Message-id: <01db01c7ea79$87b1d730$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: <01a901c7ea3d$0ad62720$1e00a8c0@cheqsoft.local> <01cd01c7ea71$2aa3cb50$1e00a8c0@cheqsoft.local> <35135D25-B5FC-410E-BBAF-DADE4F24085B@gmail.com> Cc: freebsd-questions@FreeBSD.ORG 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: Wed, 29 Aug 2007 20:18:16 -0000 Eric You are of course correct, it runs under "sh" I think that means I have to run it in a separate script file I write it as (First_Hop subs with a.b.c.1) #!/bin/sh if ! ping -c1 First_Hop >/dev/null 2>/dev/null then echo First_Hop_OK else ifconfig em0 down && ifconfig em0 up echo Restored fi Save as /etc/pinger.sh Try run: pfsense-p266ii:~# /etc/pinger.sh /etc/pinger.sh: Permission denied. Try fix: pfsense-p266ii:~# chmod 777 /etc/pinger.sh chmod: /etc/pinger.sh: Read-only file system Hmmmm I assume if it won't run here then crontab won't run it either? Kind regards David Hingston ----- Original Message ----- From: "Eric Crist" To: "Hinkie" Cc: Sent: Thursday, August 30, 2007 7:30 AM Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig em0 up) David, The script I provided assumes the sh shell. Most shell scripts have been historically written for the bourne shell. Before running the script I sent you, try typing sh at the command line. Then, run the line I sent your way. Let me know how it works for you! Eric On Aug 29, 2007, at 2:16 PMAug 29, 2007, Hinkie wrote: > Hi Eric > > Thank you for that, I think I see one thing I was doing wrong > (putting the ping into the if!) > > Running your code in the command window I get (Following the > successful ping) > > TESTV=0: Command not found. > TESTV: Undefined variable. > > As you can tell I am learning this syntax! > > Can you help me further? > > With thanks > > David Hingston > > ----- Original Message ----- > From: "Eric Crist" > To: "Hinkie" > Cc: > Sent: Thursday, August 30, 2007 2:17 AM > Subject: Re: FreeBSD Cron Job to run (ifconfig em0 down; ifconfig > em0 up) > > > On Aug 29, 2007, at 8:03 AMAug 29, 2007, Hinkie wrote: > >> Hi >> >> I want to run a cron job in /etc/crontab that runs (ifconfig em0 >> down; ifconfig em0 up) if my cables static ip gateway can't be >> pinged but I can't figure it out. I can't get the syntax that runs >> in the command window, to then put intot the crontab.... >> >> Can anyone help me? > > Here's what I'd use: > > ping -c 1 a.b.c.d; TESTV=$?; if [ $TESTV != 0 ]; then `ifconfig em0 > down`; fi > > HTH > ----- > Eric F Crist > Secure Computing Networks > > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions- > unsubscribe@freebsd.org" ----- Eric F Crist Secure Computing Networks