Register a domain and help support LQ
Go Back > Forums > Linux Forums > Linux - Desktop
User Name
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.


  Search this Thread
Old 07-03-2013, 11:12 AM   #1
Senior Member
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,477
Blog Entries: 3

Rep: Reputation: 87
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
Old 07-03-2013, 11:28 AM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 (pre-systemd)
Posts: 2,578

Rep: Reputation: 693Reputation: 693Reputation: 693Reputation: 693Reputation: 693Reputation: 693
What you want is the dnotify program.
1 members found this post helpful.
Old 07-03-2013, 03:29 PM   #3
Senior Member
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,477
Blog Entries: 3

Original Poster
Rep: Reputation: 87
Originally Posted by smallpond View Post
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?
Old 07-03-2013, 06:49 PM   #4
Senior Member
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-17.1 with Cinnamon & KDE
Posts: 1,477
Blog Entries: 3

Original Poster
Rep: Reputation: 87

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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Writing a script that will open a terminal window and run another script jeffery1 Linux - General 5 02-16-2013 03:30 PM
Seeking advice for a script to manage prices and discounts soniaholly1 Linux - Newbie 5 02-16-2012 08:47 AM
[SOLVED] Seeking advice for user creation script ramkumarramki Linux - Newbie 5 12-22-2011 06:50 PM
Seeking advice on bash script satimis Programming 6 10-11-2004 11:01 AM
Seeking advice on script satimis Programming 1 10-05-2004 03:02 PM

All times are GMT -5. The time now is 07:36 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration