#!/usr/local/bin/tcsh -f
if ($#argv == 0 ) then
    echo " Usage: seesize configFile [host host ...]"
    exit 1
endif
if (! -f $1)  then
    echo $1 not exists
    exit 1
endif


#  get alive file 
# 
set alive=`awk '$1=="alive" {print $2}' $1`
if ( "x$alive" == "x" ) then
    echo alive in config file not exists
    exit 1
endif
set datadir=`awk '$1=="datadir" {print $2}' $1`
if( "x$datadir" == "x") then
    echo datadir in config file not exists
    exit 1
endif
set datafile=`awk '$1=="datafile" {print $2}' $1`
if( "x$datafile" == "x") then
    echo datafile in config file not exists
    exit 1
endif


@ n = 0
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
@ n += 1
 if( $#argv == 2) then
	if( $f != $2 ) continue
 endif
 echo " "
 echo $n " " $f
 seeifdead  $f

 if( $status == 0 ) then 		

	 rsh $f ls -l $datadir/$f/$datafile
  else
	echo $f seems to be dead
  endif	
end


