From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48794 invoked by alias); 14 Jul 2017 13:06:10 -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 48752 invoked by uid 89); 14 Jul 2017 13:06:05 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=interpretation, reality, HContent-Transfer-Encoding:8bit X-HELO: mail-it0-f53.google.com Received: from mail-it0-f53.google.com (HELO mail-it0-f53.google.com) (209.85.214.53) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 14 Jul 2017 13:06:03 +0000 Received: by mail-it0-f53.google.com with SMTP id m68so20462317ith.1 for ; Fri, 14 Jul 2017 06:06:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=thdfCbI2An/6RwgmZJS7mMc/ha3mktBN5OP9R0Hvz1g=; b=fRJimcGGD7HJAEGkTJubgLPPbkg6GTlS4k08xOu408i9qdV33pKoX3Rz8Q7Q0o7Lj3 FcUg9XEUKSpIsQYVmOufTLNxoeyZ0CLl6Vff/OlGYnJ6fJub82Ch0DNa0jO0D5xwA468 gNI7N/eR/AECEULGHAAVib4foEFMVFqDMxCPCt+86RX8AFnINtARicytFuOz25SFGppL Tv64vq1/5cZZYBJZbWqIHvkCZbfYkvx6LNhX3PSblDJLfBU9WMxpTtOf68/tXc5Ugruy jgMzy8b735LSN1UzRAtdKnwN61V0VT438+ZmsSIPlcaWzEjvXxWwte/sUBhoFRzrt2xE uqgw== X-Gm-Message-State: AIVw1101dpvy5LbITIVlUslm2cYAr+PXDmxpP6yteiK/xtm+r2LdHx9f 3VNS6HFjR+DaH/QN X-Received: by 10.107.172.69 with SMTP id v66mr7818656ioe.127.1500037561690; Fri, 14 Jul 2017 06:06:01 -0700 (PDT) Received: from [192.168.0.6] (d4-50-42-50.try.wideopenwest.com. [50.4.50.42]) by smtp.gmail.com with ESMTPSA id i16sm4448447iod.35.2017.07.14.06.06.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 06:06:01 -0700 (PDT) Subject: Re: How to repeat a bash shell script until success To: cygwin@cygwin.com References: <97021E71-D804-42AF-8358-6276AF4514AB@gmail.com> <20170714052736.GA2895@phoenix> From: cyg Simple Message-ID: <8bb16934-972b-5d3e-918f-36eec3d16ca6@gmail.com> Date: Fri, 14 Jul 2017 17:07: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: <20170714052736.GA2895@phoenix> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2017-07/txt/msg00231.txt.bz2 On 7/14/2017 1:27 AM, Gary Johnson wrote: > 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. > In reality the OP script appears to be executed in a crontab system and executed every X minutes. So a change to the OP question is needed which is answered at[1]. Let's remember some people have no real clue as to what question they should ask and we need to interpret what is being asked into what should have been asked. If interpretation isn't possible then asking for a use case would be warranted. [1] https://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows -- cyg Simple -- 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