From owner-freebsd-questions@FreeBSD.ORG Thu Nov 4 08:26:35 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 8DD7416A4CE for ; Thu, 4 Nov 2004 08:26:35 +0000 (GMT) Received: from amsfep18-int.chello.nl (amsfep18-int.chello.nl [213.46.243.13]) by mx1.FreeBSD.org (Postfix) with ESMTP id CDE1C43D2F for ; Thu, 4 Nov 2004 08:26:33 +0000 (GMT) (envelope-from Danovitsch@Vitsch.net) Received: from Vitsch.net ([212.187.78.35]) by amsfep18-int.chello.nl (InterMail vM.6.01.03.04 201-2131-111-106-20040729) with ESMTP id <20041104082632.NOGE7692.amsfep18-int.chello.nl@Vitsch.net>; Thu, 4 Nov 2004 09:26:32 +0100 Received: from 192.168.2.131 (cp402377-c.venlo1.lb.home.nl [217.122.93.195]) by Vitsch.net (8.12.3p2/8.11.3) with ESMTP id iA48QIun004780; Thu, 4 Nov 2004 09:26:18 +0100 (CET) (envelope-from Danovitsch@Vitsch.net) From: "Daan Vreeken [PA4DAN]" To: faisal gillani Date: Thu, 4 Nov 2004 09:26:20 +0100 User-Agent: KMail/1.5.2 References: <20041104074244.25031.qmail@web54705.mail.yahoo.com> In-Reply-To: <20041104074244.25031.qmail@web54705.mail.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200411040926.20167.Danovitsch@Vitsch.net> 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 08:26:35 -0000 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