delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/07/17/09:40:28

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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=pno5hFuF1ZMypGt7
+mPA9oLF/LSo9x+Z0tkscoeBWqF3ZjTTYSrZmYAPaOVzVlEiSID7fc63l30DWx2s
eTEqc9jJ8vjAjg+4Abr6zfG3Zkm+eMemzfLKCEk2P0oq67o651vzEwL9sg6WTJI0
nMuVuxMKiIJT33jZ6h8QNTxeN6s=
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:subject:to:references:from:message-id:date
:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=cVtnxWj9DpEZ5oqyNs8MjQ
OgYHU=; b=T0sYryMaOrjBXMl08QEoKAybvD4rDlysz0Y2y5IHbU0xPbGWdz2wxs
3R/0hHSTzzfdmWAn0jwo+0hlRCqtpoi+RTvAIR8ZBI+EqzT+vJCDfYrpdovdTLyR
I3I70eytL/tiDl+HidFz6l4YDSwAkDu00yCwLB1UOi2f8gSDzKPpM=
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=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=no version=3.3.2 spammy=gutenberg, stick, interpretation, waits
X-HELO: mail-io0-f179.google.com
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=xs7dRNQP3J/Tsn46NHxLdlcty/X0aWt+LGDF12laEtw=; b=im0SlhUizLbHrcmgqQ+zIYcEu5UqWXss6bxKoirAqpywaMbWHk/kMkd1NKCHBOhlYx bFeVW1hcBT0hP+daqK5p/huHBGcERVHksjbywZpmORkNb2Kju7CTwkiSZ65Sn+SpatHf 6rSTGP+Z6g8mfSPeAMwEMC69ZPbO308aksoRNKjmaQafwNd3quipP5Z7he6V4vN1e4Kr y726MoWTn+UsHuXQQbDc1bey9qmlE7vtyPxF+LhDylvHcljZDzEURtNaR5VU1fTCajNc 6I88IjZWGhWWvSmlxC0PsU6d+F4DjXW50rgkF1MPBMmW8nMIBKYv7bAybTyUHO+DjD9K lbog==
X-Gm-Message-State: AIVw113s6b5mnfMGCnwDU/LecjVou7Q34tfleMzmkYpBEgepMJCOgRLj p6Z4X0FpL4vsBuEh
X-Received: by 10.107.151.21 with SMTP id z21mr18501571iod.205.1500298811724; Mon, 17 Jul 2017 06:40:11 -0700 (PDT)
Subject: Re: How to repeat a bash shell script until success
To: cygwin AT cygwin DOT com
References: <97021E71-D804-42AF-8358-6276AF4514AB AT gmail DOT com> <20170714052736 DOT GA2895 AT phoenix> <8bb16934-972b-5d3e-918f-36eec3d16ca6 AT gmail DOT com> <CAFeE7GnAE5JPeWMVHNNHhqGOFC_Zf_nH47RarxGiXrBNWtOo8g AT mail DOT gmail DOT com>
From: cyg Simple <cygsimple AT gmail DOT com>
Message-ID: <7fdc576e-a16f-1f8a-f539-165fa9e63027@gmail.com>
Date: Mon, 17 Jul 2017 09:40:12 -0400
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: <CAFeE7GnAE5JPeWMVHNNHhqGOFC_Zf_nH47RarxGiXrBNWtOo8g@mail.gmail.com>
X-IsSubscribed: yes

On 7/15/2017 2:56 AM, Sorin Adrian Savu wrote:
> On Fri, Jul 14, 2017 at 4:06 PM, cyg Simple <cygsimple AT gmail DOT com> wrote:
>>
>> 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
> 
> 
> Actually, the correct question would be: how do I run a bash script
> when a USB stick is mounted ?
> 
> Which is doable via Task Scheduler and a event log trigger. See
> https://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/task-scheduler-how-to-automatically-synchronize-my/45a49d83-b1d8-4d37-8896-3d2696cf9795
> on how to locate the appropriate event,
> 
> As for the script:
> 
> - don't use ls for checking file/directory presence use -f/-d (man test)
> - you will need to adjust paths (cygwin has windows drives under
> /cygdrive (cygpath -h)
> 

And don't forget the user has the option to change /cygdrive to
something else including / which is my preference.

> On how to run the script from Task Scheduler use an action like this:
> 
> C:\Tools\cygwin64\bin\bash.exe -c /cygdrive/c/tools/cygwin64/home/bryan/bkp.sh
> (adjust your paths accordingly )

Yes, if you don't want to run cygserver, this is another option.  But if
you're moving from a *nix based system then using cron under cygserver
is what you want.

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

- Raw text -


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