0

I need shell script to monitor the windows shared drive directory for any new file from the linux box and process the new file for further validation.

I wrote the script using inotify-wait, but it doesn't capture the events when drag and drop the new files to the windows machine directly or copy paste the new file on it.

Any ideas on how to implement on this?

2
  • You need to tell answerers in your question how the directory is shared. It could be SMB. It could be a VirtualBox shared folder. It could be NFS, even.
    – JdeBP
    Nov 30, 2017 at 8:43
  • Sure. I am able to access the windows directory from linux box using symlinks(mounted) and i can able to see the events captured using inotify when i do scp from my mac to the symlink Nov 30, 2017 at 12:31

1 Answer 1

0

EDIT: I may have misread your question, is the script running on a UNIX machine?

If this directory is accessible from your machine you can create a rule in auditd to watch for events that occur to the filesystem and they are viewed using aureport. It has some nice formatting for human readability and it's not too hard to learn! i remember back when i was only a beginner with linux I used this as a directory watcher on a C program i was writing in college. It worked fine on the debian os i was running. Let me know if it helps at all!

3
  • Sure. I am able to access the windows directory from linux box using symlinks(mounted) and i can able to see the events captured using inotify when i do scp from my mac to the symlink Example : scp -r {mac/test} user@10.x.x.x:/mnt/trace/files But when i connect the windows box directly from (Go-> connect -> smb://10.x.x.x/{path}) from finder and try to drag and drop some files to the respective directory(/trace/files) inotify doesn't capture the event.. So i need to use the symlink to scan the /trace/files directory for new files and process the new file for further validation. Any help ? Nov 30, 2017 at 12:42
  • i am not sure what you are referring to when you say "using symlinks" and "use the symlink to scan the directory". Is this a method that inotify uses? I know that if you have a directory on your linux box, and someone adds a file to it, auditd can track that change. I'm sure this applies to your situation if your linux machine can access /mnt/trace/files , create a rule and watch the output when you drop a file in there.
    – jamalm
    Nov 30, 2017 at 14:56
  • In relation to " But when i connect the windows box directly from (Go-> connect -> smb://10.x.x.x/{path}) from finder and try to drag and drop some files to the respective directory(/trace/files) " check on the linux side if this file is now there, if it is, your program should detect it.
    – jamalm
    Nov 30, 2017 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.