-   Linux - Desktop (
-   -   seeking help with script writing (

SaintDanBert 07-03-2013 11:12 AM

seeking help with script writing
In another thread, Seeking tool to help with file download placement I learned that I need a script to do what I want to do.

(blush) I'm hate to admit that I need help writing such a script... My script writing skills are crusted in barnacles and rust, coupled with the march of new features since I was last engaged in scripting details. Someone please help?!

Here is the context:
  • phase-1, a list of folders appear on the command line
  • scan each designated folder
  • based on each found file, move the file to a specified location
    • phase-1, 'filetype' determines where to move the file
    • phase-1, move destination hard coded per 'filetype'
  • phase-1, launch script on demand
  • phase-next
    • read folder from configuration file
    • read move targets from a configuration file
    • smarter rules than 'filetype' for what to move and where

I know that such a script might run as a daemon and crank every so often.

I can get similar results if it runs as a 'cron job'.

What I'd really like is some magic that launches the script whenever the contents of some folder gets modified. Does anyone know about that sort of magic?

~~~ 8d;-Dan

smallpond 07-03-2013 11:28 AM

What you want is the dnotify program.

SaintDanBert 07-03-2013 03:29 PM


Originally Posted by smallpond (Post 4983539)
What you want is the dnotify program.

Yes !!! 'dnotify' is exactly the sort of thing that I'm looking for.
Here is what my Linux Mint-12 workstation tells me:

prompt$ apropos dnotify
AuMakeSendNotifyAction (3nas) - initialize an action

prompt$ apropos inotify
inotify (7)          - monitoring file system events
inotify_add_watch (2) - add a watch to an initialized inotify instance
inotify_init (2)    - initialize an inotify instance
inotify_init1 (2)    - initialize an inotify instance
inotify_rm_watch (2) - remove an existing watch from an inotify instance

prompt$ which dnotify
... no response ...
prompt$ which inotify
... no response ...

'AuMakeSendNotifyAction' is part of audiolib.

I learn the following about 'inotify'

prompt$ man inotify

      inotify - monitoring file system events

      The inotify API provides a mechanism for monitoring file system events.  Inotify can be used to monitor individual files, or  to  monitor  directories.  When  a directory is monitored, inotify will return events for the directory itself, and for files inside the directory.

      The following system calls are used with  this  API:  inotify_init(2)  (or  ino‐tify_init1(2)),    inotify_add_watch(2),  inotify_rm_watch(2),  read(2),  and close(2).

I did not find 'dnotify' in my repositories. I did find a MATE desktop specific app called 'fam'. I would install that, but it has a huge dependency list including MATE itself. I'm a Cinnamon user.

Can anyone steer me to the program that smallpond mentioned?

SaintDanBert 07-03-2013 06:49 PM

After more research into 'inotify' I learned there is a package inotify-tools in the DEB-package repositories.

This package adds the command-line utilities:
  • inotifywait --wait for changes to files; either exit after any change or execute repeatedly
  • inotifywatch -- output a table on standard out with one column for each type of event and one row for each watched file or directory. The table will show the amount of times each event occurred for each watched file or directory.

All times are GMT -5. The time now is 02:53 PM.