How to hook file changes?


 
Thread Tools Search this Thread
Top Forums Programming How to hook file changes?
# 1  
Old 05-11-2008
How to hook file changes?

hello,

Im trying to create some kind of a file change hook on unix machines (should be generic if possible).

Do any of you know how can i write some code that will trigger whenever a file is being modified and then will approve the modifications, or throw an exception if the new content of the file is invalid?

I want to be able to hook specifiec files, and i know to catch any modification that any software will make..
# 2  
Old 05-12-2008
This would probably not be generic across platforms. Linux has a change notify capability now, for example. But nothing like that exists in the HPUX kernel. However, samba does have the feature enbedded, since it is a filesystem - NFS.
Other Samba Configuration Issues
So in this sense you can have change notification on a kernel with out it - by modifying the filesystem code. Which is not very practical.

If you are working in the Linux world you can read about inotify (inode notify) here:
Kernel Korner - Intro to inotify
# 3  
Old 05-12-2008
I don't think there is a generic way as Jim noted.
With *BSD supporting kqueue you can watch for vnode changes, inotify for linux or using the fcntl F_NOTIFY call (same thing).
OSX supports kqueue. On others you can just use a stat loop checking access/mod times, file size, etc...
That's probably the most generic approach.
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Enable 'make uninstall' hook?

Heyas I'm currently trying to make 'make uninstall' work properly, as it doesnt remove empty directories. To do so, i've applied: uninstall-hook: if test -d $docdir; then rmdir $docdir; fi As stated (example) in automake - 'make uninstall': Howto remove empty directories - Stack... (2 Replies)
Discussion started by: sea
2 Replies

2. Shell Programming and Scripting

Making post down hook script for svn regarding sending emails after an file is committed in svn

Hi Folks , I am asking this question but i apologise please if this is not the correct forum , I have to develop a shell script that i want to place in at hooks/post-commit , that is basically i have to develop a post hook script and the main functionality of that script would be lets say if... (0 Replies)
Discussion started by: sunsun06060606
0 Replies

3. Shell Programming and Scripting

Get Home Directory for Users in Login Hook Script

I'm writing a script to use as a LoginHook for my Mac users. As part of this script, I need to write to a location in their home directory, but I can't seem to access the path - at this point in the login process, $HOME is empty and ~ gives the path to root's home. Unfortunately, I can't just do... (1 Reply)
Discussion started by: blondepianist
1 Replies

4. UNIX for Dummies Questions & Answers

The Gary Hook tutorial

Hi All, One more time (!). I have started a contract job and am looking for any online tutorials for AIX, 5 or 5L, just an overview to brush up on system administration, security, networking, etc. with the newer and Linux linked versions. Several people on the web have indicated in other... (1 Reply)
Discussion started by: jeffpas
1 Replies

5. UNIX for Dummies Questions & Answers

The Gary Hook tutorial

Hi All, There has been talk about UNIX self-paced online tutorials written by Gary Hook, and that they are very good, specifically AIX. I am looking for the latest version of AIX, administration, tuning, networking, etc. (Like version 5 or 5L.) Basics to mid-range. I have searched all... (0 Replies)
Discussion started by: jeffpas
0 Replies

6. Solaris

Sun Blade 150 - I can't hook up extra drives

I'm not familiar with this particular machine and it's baffling me. For those that are familar with the workstation, allow me to paint a picture. If you were looking down on the machine (open) you would see the main board and then a riser board. On the left side of the riser board are jacks... (1 Reply)
Discussion started by: silversaleen68
1 Replies

7. Solaris

File System Hook

Background: DEDS is used to exchange files between Our Client and outside world. It is running on Sun v480 server OS 5.8. The files can come into or go out from various directories configured for various interfaces and come from both Our Client side as well as outside world. Requirement: ... (0 Replies)
Discussion started by: kdhana
0 Replies

8. Linux

would like to hook up linux system to another computer!

I have desktop with both windows and fedora core 2 installed on it which I have also hooked up to my psion 5mx palm device that is stored in the windows drive... and i just access the files by mounting them onto my linux drive.. now I have a laptop too .. with the same directories as the linux... (7 Replies)
Discussion started by: moxxx68
7 Replies
Login or Register to Ask a Question