#!/bin/csh

set GROUP = "ALL"

if ( "$#" == "0"|"$1" == "-h"|"$1" == "-help"|( "$1" == "-g" & "$#" <= 2)) then
  echo "oeh : execute a command on a group of computer (sysf)"
  echo "  SYNTAX : "
  echo "     oeh [-g GROUP] COMMAND"
  echo "  Where GROUP is a sysf host group. By default it is the group ALL." 
  exit(0)
endif

if ( "$1" == "-g" ) then
  set GROUP = $2
  shift
  shift
endif

echo "Group = " $GROUP

foreach host (`sysf -lhg $GROUP`)
  echo $host
  if ( "$host" == `uname -n` ) then
    $*
  else
    /usr/bin/rsh $host "$*"
  endif
end
