custom shell script .. OT maybe .

Giorgos Keramidas keramida at ceid.upatras.gr
Thu Nov 4 02:31:45 PST 2004


On 2004-11-04 09:26, "Daan Vreeken [PA4DAN]" <Danovitsch at 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.



More information about the freebsd-questions mailing list