How to repeat a bash shell script until success
Fri Jul 14 19:20:00 GMT 2017
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?
> while ! program arg1 arg2 ...
> : # explicit null statement: syntactically mandatory!
> 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
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
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin