Need an hook to the Solaris file system

Hi Friends

  I am looking for  some hook to the Solaris file system at the OS level which will generate a notification to my program whenever a file is created or deleted. The notification needs to contain the filename, filepath and the type of filechange (i.e. Creation/deletion)

Any suggestions ?

Regards
Manish

vikrant_kprAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CadburyKatCommented:
Hello,

You may need to get a little creative here.
-----------------SNIP---------------------------------
#!/bin/ksh

if [ -f /tmp/out.dat ]
then
   mv out.dat out.dat.old
fi

find /var/opt | sort > /tmp/out.dat

#This will report the differences

diff /tmp/out.dat /tmp/out.dat.old

#if you want to compare and contrast dates you will need to do something like this

if [ -f /tmp/ls.out.dat ]
then
   mv /tmp/ls.out.dat  /tmp/ls.out.dat.old
   for file in `cat /tmp/out.dat`
   do
      ls -al ${file} > /tmp/ls.out.dat
   done
fi

for file in `cat /tmp/out.dat`
do
   ls -al ${file} > /tmp/ls.out.dat
done
0
CadburyKatCommented:
OOOPS.  Use this working script:


#!/bin/ksh

touch out.dat.old

if [ -f /tmp/out.dat ]
then
   mv out.dat out.dat.old
fi


#######################################
#EDIT the directory of interest here
#######################################
find /etc/patch | sort > /tmp/out.dat

#This will report the differences
echo "#######################################"
echo "These are the files that are different"
echo "#######################################"
diff /tmp/out.dat /tmp/out.dat.old

#
#
#
#if you want to compare and contrast dates you will need to do something like this

if [ ! -f /tmp/ls.out.dat.old ]
then
   touch /tmp/ls.out.dat.old
fi

if [ -f /tmp/ls.out.dat ]
then
   mv /tmp/ls.out.dat  /tmp/ls.out.dat.old
fi

for file in `cat /tmp/out.dat`
do
   if [ ! -d ${file} ]
   then
      false
   else
      ls -al ${file} >> /tmp/ls.out.dat
   fi
done


#This will report the differences
echo "#######################################"
echo "These are the files that are different"
echo "#######################################"
diff /tmp/ls.out.dat /tmp/ls.out.dat.old
0
XoFCommented:
have a look at this thread:
http://www.experts-exchange.com/Operating_Systems/Linux/Q_21806194.html

famd for example should be available for Solaris, too AFAIK.

HTH,
-XoF-
0
NukfrorCommented:
Blastwave has fam for Solaris:

http://www.blastwave.org/packages.php/fam

Haven't used it so can't say how well it works.
0
XoFCommented:
as posted in the above mentioned thread:

#include <stdio.h>
#include <fam.h>
#include <unistd.h>

FAMConnection* fc;
FAMRequest* fr;
FAMEvent* fe;

int main(int argc,char* argv[]){
  char* dir=argv[1];
  fc = (FAMConnection*) malloc(sizeof(FAMConnection));
  fr = (FAMRequest*) malloc(sizeof(FAMRequest));
  FAMOpen(fc);
  if(fc){
    FAMMonitorDirectory(fc,dir,fr,NULL);
    if(fr){
      fe = (FAMEvent*) malloc(sizeof(FAMEvent));
      while(1){
        FAMNextEvent(fc,fe);
        switch(fe->code){
          case FAMDeleted:
            printf("File %s deleted\n",fe->filename);
            break;
          case FAMCreated:
            printf("File %s created\n",fe->filename);
            break;
        }
      }
      FAMCancelMonitor(fc,fr);
      free(fe);
    }
    FAMClose(fc);
  }
  free(fr);
  free(fc);
  return(FAMErrno);
}


Save this snippet as "dmon.c". Then do a "gcc -lfam -o dmon dmon.c".
Call the sample prog as "./dmon <directory>". (make sure, that famd is running before - no error handling implemented)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.