From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 130383 invoked by alias); 14 Jul 2017 17:34:55 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 130374 invoked by uid 89); 14 Jul 2017 17:34:54 -0000 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 Received: from smtp-out-no.shaw.ca (HELO smtp-out-no.shaw.ca) (64.59.134.12) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jul 2017 17:34:53 +0000 Received: from [192.168.1.100] ([24.64.240.204]) by shaw.ca with SMTP id W4UMdlqCiM9gtW4UNdxotl; Fri, 14 Jul 2017 11:34:51 -0600 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.Inglis@SystematicSw.ab.ca Subject: Re: How to repeat a bash shell script until success To: cygwin@cygwin.com References: <97021E71-D804-42AF-8358-6276AF4514AB@gmail.com> From: Brian Inglis Message-ID: <1e54f659-58d9-eeda-c6e2-bc619717f5f4@SystematicSw.ab.ca> Date: Fri, 14 Jul 2017 19:20:00 -0000 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 X-SW-Source: 2017-07/txt/msg00233.txt.bz2 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