#!/usr/local/bin/tcsh -f
#
#   rmpath config 
#   rm directories starting from  datadir in config file
if( $#argv == 0 ) then
    echo "Usage: rmpath configFile [host host ...]"
    exit 1
endif
set datadir=`awk '$1=="datadir" {print $2}' $1`
if ( x$datadir == "x" ) then
    echo no datadir in config file = $1
    exit
endif
set alive=`awk '$1=="alive" {print $2}' $1`
foreach f(`cat $alive`)
   if(  $#argv >= 2) then
      if(`echo "$argv[2*]" | gawk '{if(index($0, h) >0 ) print "x";else print "y"}' h=$f -` == "y") continue
    endif
	echo $f
	seeifdead  $f
	if ( $status == 0 ) then
		rsh $f  rm -fr  $datadir
		echo $datadir  in  $f removed
	else
		echo $f seems dead
	endif	
end
