#include #include #include #include #include #include #include #include #include #include char base[] = "/usr/ftp/physics/pub/ITERProfileDatabase1998"; int chm=0; int count = 0; /***************************************************************/ void scan_dir(char *name, int offset) {DIR *dir,*dir2; struct dirent *dp; int i; char *s,*p; char str[250]; chdir(name); dir=opendir("."); if(dir==NULL) {printf("Dir not found\n");exit(0);} while((dp=readdir(dir)) != NULL) {if((dir2=opendir(dp->d_name))!=NULL) {closedir(dir2); if(dp->d_name[0] != '.' && strcmp(dp->d_name,"software")!= 0 && strcmp(dp->d_name,"documents")!= 0 && strcmp(dp->d_name,"scripts")!= 0 && strcmp(dp->d_name,"review_sheets")!= 0 ) { sprintf(str,"chmod a+rx %s",dp->d_name); system(str); fprintf(stdout,"%s\n",dp->d_name); scan_dir(dp->d_name,offset + 1); } } else { sprintf(str,"chmod a+r %s",dp->d_name); system(str); } } closedir(dir); chdir(".."); } /**********************************************************************************/ main(int argc,char *argv[]) { scan_dir(base,0); }