X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; q=dns; s=default; b=oBjw62bdftD0KOfj994KYyHJoumdNv xKtZBQywlc3DxgT/F7Qq+QaWzmsx/RHHHRdq+jMs65ELSw/b8lyoNfn9vWW8sh7T 13/J9i383+upYRqMHnrnaEnL1BHJsguvv54d+Mfg48MOZFizQK0xgyWYqiYgna6b kaEXNxnAD4+/w= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:content-transfer-encoding :in-reply-to; s=default; bh=0Gzgl8K3YIVSQs76h0RH0RvszrU=; b=sz8x VzsVBFfYezqWm2/o4T0K9aEJGwu/AltKKPiGqBwGkvvJTPENJzDnB92+jeUeapWA ViX5OHn0pUQwHuVf0YRhEyAixP6j/Pc9LwTv0oBT1jUpwv3S5XrxUtsGX/gQZEIP iU8+hkzp9O5Zsk9US04HZcFSIU6UcBDtzl/FhW8= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_PASS autolearn=unavailable version=3.3.2 spammy=HContent-Transfer-Encoding:8bit X-HELO: mail.spocom.com Date: Thu, 13 Jul 2017 22:27:36 -0700 From: Gary Johnson To: cygwin AT cygwin DOT com Subject: Re: How to repeat a bash shell script until success Message-ID: <20170714052736.GA2895@phoenix> Mail-Followup-To: cygwin AT cygwin DOT com References: <97021E71-D804-42AF-8358-6276AF4514AB AT gmail DOT com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <97021E71-D804-42AF-8358-6276AF4514AB@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes On 2017-07-12, Bryan Dunphy wrote: > I have a shell script, originally created for Mac OS X. that waits > for an external drive to be mounted (by testing an “ls” of the > volume’s root directory for success) then runs an “rsync” command. > How do I get the script to be run repeatedly until successful exit > under Cygwin? > > Here is the unmodified Mac OS version of the script: > > #!/bin/bash > if ls /Volumes/Shared >/dev/null 2>/dev/null > then > rsync -avz --compress-level=9 --delete-during --partial --exclude 'cache/' aleph.gutenberg.org::gutenberg /Volumes/Shared/Project-Gutenberg > exit 0 > else > exit 1 > fi Let the name of your script be "myscript". The following will run myscript every two seconds until it succeeds. while ! myscript; do sleep 2; done This is really a bash programming question and is not specific to Cygwin. Regards, Gary -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple