On Saturday 30 April 2005 23:21, Laurent Renard wrote:
#include
#include #include #include #include int main(int argc, char *argv[]){ FAMConnection fc; FAMRequest fr; FAMEvent fe; DIR *dir; struct dirent *entry;
printf("Monitoring directory %s\n", argv[1]);
if(FAMOpen(&fc)){ fprintf(stderr, "Couldn't open connection to FAM daemon\n"); exit(1); }
if(FAMMonitorDirectory(&fc, argv[1], &fr, NULL)) exit(1);
while(FAMNextEvent(&fc, &fe) != -1){ printf("The directory changed\n"); dir = opendir(argv[1]); while((entry = readdir(dir)) != NULL) printf("%s\n", entry->d_name); closedir(dir); } FAMClose(&fc); return 0; }
It seems that i need a few more libs to execute it or is there a place where i could drop it to run ?
You need to compile it, and you need to have the package fam-devel installed. Save it in a file called dirmonitor.c, then compile it with gcc -lfam -o dirmonitor dirmonitor.c Then run it with ./dirmonitor <full path to directory to monitor> Or you can get a precompiled version from ftp://rydsbo.net/pub/dirmonitor (source is ftp://rydsbo.net/pub/dirmonitor.c) Then you'll only need to make sure you have fam installed, and that the fam daemon is running (rcfam start) But it really is a very simple program. If you told me what you're after exactly, I could improve it