From owner-freebsd-questions@FreeBSD.ORG Thu Nov 4 10:31:45 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2A7BE16A4CE for ; Thu, 4 Nov 2004 10:31:45 +0000 (GMT) Received: from aiolos.otenet.gr (aiolos.otenet.gr [195.170.0.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0429043D54 for ; Thu, 4 Nov 2004 10:30:34 +0000 (GMT) (envelope-from keramida@ceid.upatras.gr) Received: from orion.daedalusnetworks.priv (aris.bedc.ondsl.gr [62.103.39.226])iA4AUGgZ005407; Thu, 4 Nov 2004 12:30:21 +0200 Received: from orion.daedalusnetworks.priv (orion [127.0.0.1]) iA4AUEAW001414; Thu, 4 Nov 2004 12:30:14 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Received: (from keramida@localhost)iA4AUDeU001413; Thu, 4 Nov 2004 12:30:13 +0200 (EET) (envelope-from keramida@ceid.upatras.gr) Date: Thu, 4 Nov 2004 12:30:13 +0200 From: Giorgos Keramidas To: "Daan Vreeken [PA4DAN]" Message-ID: <20041104103013.GA1325@orion.daedalusnetworks.priv> References: <20041104074244.25031.qmail@web54705.mail.yahoo.com> <200411040926.20167.Danovitsch@Vitsch.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200411040926.20167.Danovitsch@Vitsch.net> cc: faisal gillani cc: freebsd-questions@freebsd.org Subject: Re: custom shell script .. OT maybe . X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Nov 2004 10:31:45 -0000 On 2004-11-04 09:26, "Daan Vreeken [PA4DAN]" wrote: > On Thursday 04 November 2004 08:42, faisal gillani wrote: > > Hello there ... > > > > well i want to make a simple/wieard shell script :) > > which checks somehow > > connection with the internet & rename some file files > > if it finds > > connectivity with the internet , & do nothing of it > > dont find connectivity > > with the internet ...is it possible with simple shell > > script ? or do i have > > to learn some scripting language for that ? > > CAN U HELP !!! :) > > Try something like this : > ---- cut here ----- > #!/bin/sh > > connection=0 > ping -c 5 -t 6 some.host.on.the.internet && connection=1 Ping may be a bit unreliable at times. If you know the interface name you can probably get away by using ifconfig to short-cut through the checks. flags=$(ifconfig sis0 | grep '^sis0:' | \ sed -e 's/.*.*//' ) case $flags in *UP*) # interface is up, keep going ;; *) echo "sis0 interface is down." exit 1 ;; esac Replace sis0 with tun0 and you have something that works just fine for dialup PPP connections ;-) Just my USD $0.02.