Date: Thu, 4 Nov 2004 09:26:20 +0100 From: "Daan Vreeken [PA4DAN]" <Danovitsch@Vitsch.net> To: faisal gillani <fasi_74@yahoo.com> Cc: FreeBSD-Questions@FreeBSD.org Subject: Re: custom shell script .. OT maybe . Message-ID: <200411040926.20167.Danovitsch@Vitsch.net> In-Reply-To: <20041104074244.25031.qmail@web54705.mail.yahoo.com> References: <20041104074244.25031.qmail@web54705.mail.yahoo.com>
next in thread | previous in thread | raw e-mail | index | archive | help
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 if [ "${connection}" = "1" ]; then # This will be executed if we can ping the host echo "We have internet. :)" else # This will be executed if we can't ping the host (no connection) echo "Oh no!! Someone please help me." echo "We're not connected!!" fi ---- end of script --- The "ping" command tries to ping some host on the internet 5 times and waits for a maximum of 6 seconds for a reply. If ping gets a reply, the variable "connection" will be set to 1. The "if" statement checks the "connection" variable and executes whatever you want to do then. grtz, Daan
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200411040926.20167.Danovitsch>