From: Brian Inglis <Brian.Inglis@SystematicSw.ab.ca>
To: cygwin@cygwin.com
Subject: Re: How to repeat a bash shell script until success
Date: Fri, 14 Jul 2017 19:20:00 -0000 [thread overview]
Message-ID: <1e54f659-58d9-eeda-c6e2-bc619717f5f4@SystematicSw.ab.ca> (raw)
In-Reply-To: <f5f430ae9099269d19a00df239644c1d@mail.kylheku.com>
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
next prev parent reply other threads:[~2017-07-14 17:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 0:16 Bryan Dunphy
2017-07-14 1:12 ` Brian Inglis
2017-07-14 5:31 ` Gary Johnson
2017-07-14 13:06 ` Gary Johnson
2017-07-14 17:07 ` cyg Simple
2017-07-15 18:40 ` Sorin Adrian Savu
2017-07-17 17:41 ` cyg Simple
2017-07-17 17:46 ` Ian Lambert via cygwin
2017-07-14 17:34 ` Kaz Kylheku
2017-07-14 19:20 ` Brian Inglis [this message]
2017-07-14 19:23 Kaz Kylheku
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1e54f659-58d9-eeda-c6e2-bc619717f5f4@SystematicSw.ab.ca \
--to=brian.inglis@systematicsw.ab.ca \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).