LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices


Reply
  Search this Thread
Old 07-03-2013, 11:12 AM   #1
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
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?

Cordialement,
~~~ 8d;-Dan
 
Old 07-03-2013, 11:28 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,140

Rep: Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263Reputation: 1263
What you want is the dnotify program.
 
1 members found this post helpful.
Old 07-03-2013, 03:29 PM   #3
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108
Quote:
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:
Code:
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'
Code:
prompt$ man inotify

NAME
       inotify - monitoring file system events

DESCRIPTION
       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
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint-20.1 with Cinnamon
Posts: 1,771

Original Poster
Blog Entries: 3

Rep: Reputation: 108Reputation: 108

Follow-up:
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop

All times are GMT -5. The time now is 11:43 AM.

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