Date: Thu, 4 Nov 2004 12:30:13 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net> Cc: freebsd-questions@freebsd.org Subject: Re: custom shell script .. OT maybe . Message-ID: <20041104103013.GA1325@orion.daedalusnetworks.priv> In-Reply-To: <200411040926.20167.Danovitsch@Vitsch.net> References: <20041104074244.25031.qmail@web54705.mail.yahoo.com> <200411040926.20167.Danovitsch@Vitsch.net>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2004-11-04 09:26, "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net> 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/.*<//' -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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20041104103013.GA1325>