#!/bin/csh -f
if ( $#argv != 1 ) then
	echo "Usage: ./execflesh_one HostList_path"
	exit
endif
 loop: 
 echo  "Give a list of hostnames for flesh."
 echo  "They must be some of those listed in $1"
 set hostname="$<"
 echo "You gave: "
 echo $hostname
 echo "Is it OK?; Enter y if yes"
 set yesno=$<
 if ( x$yesno != "xy" ) goto loop
 foreach exechost ( $hostname )
       echo $exechost;
       set numb = ` awk '$2==host {printf("%3.3d"), $1}' host=$exechost $1 `
       if ( x$numb == "x" ) then
         echo "$exechost not exist in $1"
	 goto loop
       endif
 end

 echo "all hosts have been verified ; they are in $1"
 foreach exechost ( $hostname )
#       echo $exechost;
       set numb = ` awk '$2==host {printf("%3.3d"), $1}' host=$exechost $1 `
       echo $numb  $exechost;
       sed "/^[^#]/s/_/$numb/g"   exectemplate  > exec;

       chmod +x exec;
       echo command used at $exechost is ;
       awk 'substr($1,1,1) != "#"' ./exec
       ssh $exechost  $COSMOSTOP/UserHook/Distributed/$FLESHDIR/exec;
       sleep 1;
  end


























































