• Watchdog tool to observe files and directories?

    From Benjamin Esham@21:1/5 to Janis Papanagnou on Sat Jul 31 14:41:06 2021
    Janis Papanagnou wrote:

    On 19.11.2020 08:57, David W. Hodgins wrote:

    On Thu, 19 Nov 2020 02:26:56 -0500, Janis Papanagnou
    <janis_papanagnou@hotmail.com> wrote:

    Search about inotify

    Thanks. But this looks like a C-programming interface. Rather than a
    programming interface I'd be looking either for an existing command line >>> tool or programming options that I can use for shell scripting the task.

    See the output of the commands "inotifywait -h" and "inotifywatch -h"
    from the inotify-tools package.

    It seems that is it. Thanks!

    (Late answer, I know...) It sounds like you only need a Linux solution, but
    if you want something more portable later, you might consider fswatch [1].
    It's a command-line tool that provides a common interface to OS-specfic ways
    of watching files: inotify on Linux, the File System Events API on macOS, kqueue on some BSDs, and so on.

    [1] https://emcrisostomo.github.io/fswatch/

    Benjamin

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to Janis Papanagnou on Thu Aug 5 01:05:46 2021
    On Thursday, November 19, 2020 at 11:35:41 AM UTC+8, Janis Papanagnou wrote:
    I want to inspect file status information and directory contents
    by some watchdog tool; e.g. new files appearing in a directory or
    a file update should be detected and indicated by an alert window.
    This should work only on dedicated files or directories, say, by
    calling the tool with the respective name and/or file attributes.
    Before I'm going to write my own command line tool I'd be interested
    if there's something like that already existing.

    There is a very helpful discussion here:

    https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes

    HY

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From hongyi.zhao@gmail.com@21:1/5 to hongy...@gmail.com on Thu Aug 5 02:56:27 2021
    On Thursday, August 5, 2021 at 4:05:49 PM UTC+8, hongy...@gmail.com wrote:
    On Thursday, November 19, 2020 at 11:35:41 AM UTC+8, Janis Papanagnou wrote:
    I want to inspect file status information and directory contents
    by some watchdog tool; e.g. new files appearing in a directory or
    a file update should be detected and indicated by an alert window.
    This should work only on dedicated files or directories, say, by
    calling the tool with the respective name and/or file attributes.
    Before I'm going to write my own command line tool I'd be interested
    if there's something like that already existing.
    There is a very helpful discussion here:

    https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes

    Based on the suggestions given in the above discussion, I currently use the following code snippet:

    inotifywait --quiet --monitor --event modify some-file-under-watch | while read change; do
    do-something-here
    done

    HY

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to hongy...@gmail.com on Sat Aug 7 02:03:04 2021
    On 05.08.2021 11:56, hongy...@gmail.com wrote:
    On Thursday, August 5, 2021 at 4:05:49 PM UTC+8, hongy...@gmail.com wrote:
    On Thursday, November 19, 2020 at 11:35:41 AM UTC+8, Janis Papanagnou wrote: >>> I want to inspect file status information and directory contents
    by some watchdog tool; e.g. new files appearing in a directory or
    a file update should be detected and indicated by an alert window.
    This should work only on dedicated files or directories, say, by
    calling the tool with the respective name and/or file attributes.
    Before I'm going to write my own command line tool I'd be interested
    if there's something like that already existing.
    There is a very helpful discussion here:

    https://superuser.com/questions/181517/how-to-execute-a-command-whenever-a-file-changes

    Based on the suggestions given in the above discussion, I currently use the following code snippet:

    In my case (the task behind the original post) it is something like

    inotifywait -q -m -e create -e delete "${dir}" |
    while read WHERE EVENT FILE
    ...check for file pattern and trigger a 'zenity' dialog...

    i.e. triggering 'create' and 'delete' events on files matching a
    specific pattern, and notifying about those events using 'zenity'.

    ('zenity' isn't optimal here, but each tool has it's drawbacks.)

    Janis


    inotifywait --quiet --monitor --event modify some-file-under-watch | while read change; do
    do-something-here
    done

    HY


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)