* Watcher script - please comment
@ 2010-05-05 11:25 Helmut Jarausch
2010-05-05 12:14 ` Sebastian Stark
2010-05-05 15:27 ` Matt Wright
0 siblings, 2 replies; 5+ messages in thread
From: Helmut Jarausch @ 2010-05-05 11:25 UTC (permalink / raw)
To: zsh-users
Hi,
I'd like to start a "daemon" which notifies me if some file
is no longer accessed (e.g. by rsync from a remote host).
My simple minded solution is
#!/bin/zsh
while /bin/true; do
if ! fuser -s $1; then break; fi
sleep 5
done
notifier -1 -e5 -tREADY <<< $1
where the file in question is passed as a parameter.
Is there something builtin into ZSH which is more efficient / elegant.
Many thanks for a hint,
Helmut.
--
Helmut Jarausch
Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Watcher script - please comment
2010-05-05 11:25 Watcher script - please comment Helmut Jarausch
@ 2010-05-05 12:14 ` Sebastian Stark
2010-05-05 12:52 ` Sebastian Stark
2010-05-05 15:27 ` Matt Wright
1 sibling, 1 reply; 5+ messages in thread
From: Sebastian Stark @ 2010-05-05 12:14 UTC (permalink / raw)
To: jarausch; +Cc: zsh-users
Am 05.05.2010 um 13:25 schrieb Helmut Jarausch:
> I'd like to start a "daemon" which notifies me if some file
> is no longer accessed (e.g. by rsync from a remote host).
Under Linux, an elegant solution would be incron:
http://inotify.aiken.cz/?section=incron&page=about&lang=en
Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Watcher script - please comment
2010-05-05 12:14 ` Sebastian Stark
@ 2010-05-05 12:52 ` Sebastian Stark
2010-05-05 14:57 ` Helmut Jarausch
0 siblings, 1 reply; 5+ messages in thread
From: Sebastian Stark @ 2010-05-05 12:52 UTC (permalink / raw)
To: Sebastian Stark; +Cc: jarausch, zsh-users
Am 05.05.2010 um 14:14 schrieb Sebastian Stark:
>
> Am 05.05.2010 um 13:25 schrieb Helmut Jarausch:
>> I'd like to start a "daemon" which notifies me if some file
>> is no longer accessed (e.g. by rsync from a remote host).
>
> Under Linux, an elegant solution would be incron:
>
> http://inotify.aiken.cz/?section=incron&page=about&lang=en
Even better (still under linux):
Install inotify-tools and run:
inotifywait -e close_write ~/testfile
Once ~/testfile is closed inotifywait exits.
Sebastian
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Watcher script - please comment
2010-05-05 12:52 ` Sebastian Stark
@ 2010-05-05 14:57 ` Helmut Jarausch
0 siblings, 0 replies; 5+ messages in thread
From: Helmut Jarausch @ 2010-05-05 14:57 UTC (permalink / raw)
To: Sebastian Stark; +Cc: zsh-users
On 5 May, Sebastian Stark wrote:
> Even better (still under linux):
>
> Install inotify-tools and run:
>
> inotifywait -e close_write ~/testfile
>
> Once ~/testfile is closed inotifywait exits.
>
Many thanks, Sebastian, for this perfect solution
Helmut.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Watcher script - please comment
2010-05-05 11:25 Watcher script - please comment Helmut Jarausch
2010-05-05 12:14 ` Sebastian Stark
@ 2010-05-05 15:27 ` Matt Wright
1 sibling, 0 replies; 5+ messages in thread
From: Matt Wright @ 2010-05-05 15:27 UTC (permalink / raw)
To: jarausch; +Cc: zsh-users
I know it's dirty but I use this to check if my dotfiles git repository has new updates available. I wonder if you could adapt that.
#!/bin/zsh
# register a SIGUSR1 handler, this will let us catch a message from
# the spawned subshell below.
TRAPUSR1() {
[[ -o zle ]] && zle -I
echo "NOTE: A dotfiles update is available in git."
# reset trap USR1 so we're not hogging it
trap - USR1
}
# grab the current PID so we can signal ourselves, the &| at the end of the
# brackets cause us to disown the child so they don't print on our window.
PID=$$
(
cd ~/.dotfiles
# make sure we never ask for a password with this check
export GIT_SSH="${HOME}/.dotfiles/tools/quiet-ssh.sh"
l=$(git rev-list master | head -1)
r=$(git ls-remote origin heads/master | awk '{print $1}')
if [[ "${r}" != "$(git merge-base ${r} ${l} 2>/dev/null)" ]]; then
# signal ourselves to write on the terminal
kill -USR1 $PID
fi
) 2>/dev/null &|
On May 5, 2010, at 4:25 AM, Helmut Jarausch wrote:
> Hi,
>
> I'd like to start a "daemon" which notifies me if some file
> is no longer accessed (e.g. by rsync from a remote host).
>
> My simple minded solution is
>
> #!/bin/zsh
>
> while /bin/true; do
> if ! fuser -s $1; then break; fi
> sleep 5
> done
> notifier -1 -e5 -tREADY <<< $1
>
>
> where the file in question is passed as a parameter.
>
> Is there something builtin into ZSH which is more efficient / elegant.
>
> Many thanks for a hint,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-05-05 16:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-05 11:25 Watcher script - please comment Helmut Jarausch
2010-05-05 12:14 ` Sebastian Stark
2010-05-05 12:52 ` Sebastian Stark
2010-05-05 14:57 ` Helmut Jarausch
2010-05-05 15:27 ` Matt Wright
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).