View previous topic :: View next topic |
Author |
Message |
ultraViolet Apprentice
Joined: 03 Apr 2004 Posts: 280 Location: Lyon, France
|
Posted: Sun Apr 27, 2008 12:06 pm Post subject: Launching a shell script on file operations [solved] |
|
|
Hi,
I would like to launch a script each time a copy, delete, rename, move operation occurs on a given folder. I know it is possible with crontab but I would like to launch the script only if it is necessary, and I would like this script to be activated in real time.
Thank for any answer
Last edited by ultraViolet on Sun Apr 27, 2008 7:07 pm; edited 1 time in total |
|
Back to top |
|
|
i92guboj Bodhisattva
Joined: 30 Nov 2004 Posts: 10315 Location: Córdoba (Spain)
|
Posted: Sun Apr 27, 2008 6:15 pm Post subject: |
|
|
I do this to show a popup notification when a new file arrives via mldonkey.
First, you need this:
Code: |
emerge sys-fs/inotify-tools
|
Now, you can run something like this:
Code: |
inotifywait -mrq --excludei .*\.tmp --format "%f" --event create --event move /storage/downloads/ | while read newfile; do (notify-send --expire-time=30000 --icon=/usr/share/icons/hicolor/32x32/apps/kmldonkey.png "Nuevo archivo recibido:" "$newfile"&); done
|
Now, you can test it by doing a simple touch on any file inside that directory, for example:
Code: |
touch /storage/downloads/test
|
And a popup should show, saying that the file called "test" has just arrived. Of course, you can use any other notifier, like kdialog for example, or trigger any other arbitrary action. That's just an example. |
|
Back to top |
|
|
ultraViolet Apprentice
Joined: 03 Apr 2004 Posts: 280 Location: Lyon, France
|
Posted: Sun Apr 27, 2008 7:07 pm Post subject: |
|
|
Thanks. Exactly what I needed, opening all possibilities. I want this to make a folder with shorcuts revealing new items or automatically sorting files depending on imdb data.
Thanks again |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|