#!/usr/local/bin/tcsh -f
#
#   rmfile config 
#   rm disk files used for storing data
if( $#argv == 0 ) then
    echo "Usage: rmfile 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 datafile=`awk '$1=="datafile" {print $2}' $1`
if ( x$datafile == "x" ) then
    echo no datafile 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/$f/$datafile
		echo $datadir/$f/$datafile  in  $f removed
	else
		echo $f seems dead
	endif	
end
