#!/usr/athena/bin/perl

$fscmd = $ARGV[0];
shift;
  if($ARGV[0]=~/neg/) { $neg = "-negative";
  shift;}
  else {$neg = "";}
$group = $ARGV[0];
$perms = $ARGV[1];
open(LOG, ">>/tmp/zcflog");
open(CLA, ">>/tmp/classes");
select(LOG);$|=1;
select(CLA);$|=1;
select(STDOUT);
$odir = '/afs/athena/user';
&fsdir($odir);


sub fsdir {
	local($d) = @_;
	local(@fasd);

	$level++;
	print($d."\n") if $level==4;
	print(LOG "Looking in $d\n");
	if(-e "$d/.zephyr.subs"){
		$subs = `cat $d/.zephyr.subs`;
		@subs = split("\n", $subs);
		for $sub (@subs){
				split(/,/, $sub);
				print($_[0]."\n") if !$class{$_[0]};
				print(CLA $_[0]."\n") if !$class{$_[0]};
				$class{$_[0]} = 1;
			}
	}
	opendir(ID, $d);
	$dit = ".";
	while($dit ne "") {$dit =readdir(ID);
	push(@fasd, $dit); }
	closedir(ID);
	foreach $p (@fasd) {
		if((-d $d."/".$p) && ($p ne ".") && ($p ne "..") && ($p ne "")) {
			$nd = $d."/".$p;
			&fsdir($nd) if $level < 4;
		}
	}
	$level--;
}
