delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/07/14/13:07:50

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:to:subject:mime-version:content-type
:content-transfer-encoding:date:from:in-reply-to:references
:message-id; q=dns; s=default; b=B2pU+KyvXE+dsmJeH0OLQ3oaDEgjPeh
5awNIiPTGKmzIa49NgM5AhrOAjDWIWg0/JbCsDPwoAGxNN8TBAyqwFxlYmVNgMUp
clxsjozdNfwBYPuIzg5el5T+RWRlQr/KJZklulU3sHSnYZq6zMvLwbEMv26iyQU1
K/fE0+SfRt9o=
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:to:subject:mime-version:content-type
:content-transfer-encoding:date:from:in-reply-to:references
:message-id; s=default; bh=r4PVGduNtGaPbPLXokihvLTesoM=; b=cA3YC
qSXsON63LEdORbFVKNO92OocmMuCfV8MB9PPxZRHyEhrlih3CgTZoXGuB/IM8lf1
JaHo/pGXFYfQ9FnG05C29ox41kgOzIErhRv0Wy+4yTU1/jv9p4lYiX31+i3FFXVx
HrOfvuzFCvzc/YBUFwU9BOP2AeN5OLtNl2uY+I=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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=-0.2 required=5.0 tests=AWL,BAYES_20,FROM_STARTS_WITH_NUMS,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:sk:smtp-ou, H*RU:sk:smtp-ou, H*r:www-data, HX-HELO:sk:smtp-ou
X-HELO: smtp-out-so.shaw.ca
X-Authority-Analysis: v=2.2 cv=B4DJ6KlM c=1 sm=1 tr=0 a=95A0EdhkF1LMGt25d7h1IQ==:117 a=95A0EdhkF1LMGt25d7h1IQ==:17 a=IkcTkHD0fZMA:10 a=SMorJkV_YP8A:10 a=G3gG6ho9WtcA:10 a=-bsX8nxf8LLtgq3p5B4A:9 a=QEXdDO2ut3YA:10
To: cygwin AT cygwin DOT com
Subject: Re: How to repeat a bash shell script until success
X-PHP-Originating-Script: 501:rcmail.php
MIME-Version: 1.0
Date: Fri, 14 Jul 2017 10:07:29 -0700
From: Kaz Kylheku <920-082-4242 AT kylheku DOT com>
In-Reply-To: <97021E71-D804-42AF-8358-6276AF4514AB@gmail.com>
References: <97021E71-D804-42AF-8358-6276AF4514AB AT gmail DOT com>
Message-ID: <f5f430ae9099269d19a00df239644c1d@mail.kylheku.com>
X-Sender: 920-082-4242 AT kylheku DOT com
User-Agent: Roundcube Webmail/0.9.2
X-CMAE-Envelope: MS4wfF9f6yrtNPF+SeT3Fd34ZiEwEMDuLYPjb0bOOu6/S67sHoE3ad7C9gC018fRf/A6UqX7KTr4Nugq66QfA28CoOtVMILYL2RvuNehqv5Tvp4H3GNnuECE LFYJT3ovxMsd2Sh9ppA3EUoLFd7hqNq65weg3T0PuHf3XXAyLuEWR+t2
X-IsSubscribed: yes

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


--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019