when-changed (GitHub) monitors files, and when any of the monitored files changed it runs the command, detail usage is shown as follows:
$ when-changed -h when-changed - run a command when a file is changed Usage: when-changed [-r] FILE COMMAND... when-changed [-r] FILE [FILE ...] -c COMMAND FILE can be a directory. Watch recursively with -r. Use %f to pass the filename to the command. Copyright (c) 2011, Johannes H. Jensen. License: BSD, see LICENSE for more details.
A quick example of how it looks like when monitoring:
$ when-changed helloworld.c gcc -o helloworld helloworld.c When 'helloworld.c' changes, run 'gcc -o helloworld helloworld.c
If you change the file or simply touch it, the command will be executed. However, there is no visual notifications and no result reporting of the command like exit status. The command may succeed or fail, only you don’t know about it.
You can also use -r with %f in command string, which will be replaced by the changed file, for example:
$ ./when-changed -r helloworld.c gcc %f -o helloworld When 'helloworld.c' changes, run 'gcc %f -o helloworld'
It’s a simple monitors, nothing complex stuff, runs on Python 2.6+ with pyinotify.
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.