#!/usr/local/bin/tcsh -f
#   /bin/csh  does not work at line ##%%##
#   

if ($#argv == 0) then
    echo " Usage: lastev configFile  [host host ...]"
    exit 1
endif
if (! -f $1)  then
    echo $1 not exists
    exit 1
else
    echo config file is: $1 
endif


#  get input parameter specification file
    set input=`awk '$1=="input" {print $2}' $1`
    if ( "x$input" == "x") then
	echo input in $1 not exists
	exit 1
    else if(! -f $input) then
       echo $input not exists
       exit 1
    endif

#  get parameter output base dir
    set paramOut=`awk '$1=="paramOut" {print $2}' $1` 
    if ( "x$paramOut" == "x") then
	echo paramOut not exists in $1
	exit 1
    else if (! -d $paramOut ) then
	echo directory $paramOut not exists
	exit 1
    endif

#    get alive 
    set alive=`awk '$1=="alive" {print $2}' $1` 
    if ( "x$alive" == "x") then
	echo alive not exists in $1
	exit 1
    else if (! -f $alive ) then
	echo alive file  $alive not exists
	exit 1
    endif

#
foreach machine (`cat $alive`)
onintr -
  if( $#argv >= 2 )  then
     if(`echo "$argv[2*]" | gawk '{if(index($0, h) >0 ) print "x";else print "y"}' h=$machine -` == "y") continue
  endif
echo  "---------------------------------" $machine
rsh $machine  tail $paramOut/$machine/Seed

sleep 3
end






