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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=U6rj2sa/Ebp6O1CN L2g0zvhlgfI6TBYDx0Q5CtcfTArpfVnyjJF/9iZm+/fTiPcBttQayFMGcHqAAMTA k92hRj+IWebKGPav3nm4GE70bmWsIkrX3AfSpv2vMmlWM0u+ajMwtbvDksha+T4G lZ9mIMTxaw4uAoAnFrZQiXpPyXQ= 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:reply-to:subject:to:references:from:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=YzyNgbcnKMWWrSMHTL0Ltn 457vY=; b=V7203dQvZXrpybuRNSlshptuISSVXW2n2eccJt4ro0NLaxXJntU+5+ O3HRt2QwrJQHkMcl/eGg7utijiNsn5neeWotTD/OAsjolJNc8B7Ly60P5kppeCb+ Z14gjbwbNfja7JZ8l74RZt4dADEXkcBc7BMfERQ4hYxpfJo7fdZaM= 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.8 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_DNSWL_LOW autolearn=no version=3.3.2 spammy=HContent-Language:en-CA, H*r:sk:smtp-ou, H*Ad:D*ab.ca, H*f:sk:f5f430a X-HELO: smtp-out-no.shaw.ca X-Authority-Analysis: v=2.2 cv=a+JAzQaF c=1 sm=1 tr=0 a=MVEHjbUiAHxQW0jfcDq5EA==:117 a=MVEHjbUiAHxQW0jfcDq5EA==:17 a=IkcTkHD0fZMA:10 a=iD4dFdpyhMUSlSwVvk0A:9 a=QEXdDO2ut3YA:10 Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca Subject: Re: How to repeat a bash shell script until success To: cygwin AT cygwin DOT com References: <97021E71-D804-42AF-8358-6276AF4514AB AT gmail DOT com> From: Brian Inglis Message-ID: <1e54f659-58d9-eeda-c6e2-bc619717f5f4@SystematicSw.ab.ca> Date: Fri, 14 Jul 2017 11:34:50 -0600 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfL/bjJFzQtyTSsB+twpEZj7E3xdJ08NXKHz63gkRinQ1CgGm3Bypxwl5D0O9UesggRNBmhiu+qae+GVfeiLaYfPCBifpfa/xTqyauW0SNZF6Vhr5izFM 3j2XUfVT0ojaX/WHL8YI587FCMrVTJmivOOIGXGlo9tmmo1fiJngNoNQMqM5ywARWvfkg7JInc5icQ== X-IsSubscribed: yes On 2017-07-14 11:07, Kaz Kylheku wrote: > On 12.07.2017 08:35, 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? > Multi-line > while ! program arg1 arg2 ... > do > : # explicit null statement: syntactically mandatory! > done > one-liner: semicolon between program and "do", > semicolon between : statement and "done": > while ! program arg1 arg2 ... ; do : ; done > The space between ! and the command is required. > I would throw a sleep in there, not to create a CPU-intensive > busy loop: > while ! program args ... ; do > sleep 1 > done Has everyone forgotten there is also an until loop, supported by at least sh, dash, bash, [m]ksh: until prog ...; do sleep 60; done -- Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada -- 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