#!/bin/csh -f
#
#       %W% %E%
#

set sapath = $argv[1]
set rmmach = $argv[2]
shift argv
shift argv

# set logfile = ${GIG_D_ROOT}/projects/renmanadm/curf_${rmmach}/gigrs_logfile

# echo $0 $argv >> ${logfile}

if ( $argv[1] == 'lost' ) then

  shift argv
# skip ALL arguments and get project
  set arguments = `getopt vVr:i:o:dp:f $argv`
  foreach i ( $arguments )
    switch ( $i )
      case '-d'
        shift arguments
        breaksw
      case '-f'
        shift arguments
        breaksw
      case '-v'
        shift arguments
        breaksw
      case '-V'
        shift arguments
        breaksw
      case '-r'
        shift arguments
        shift arguments
        breaksw
      case '-o'
        shift arguments
        shift arguments
        breaksw
      case '-p'
        set project = $arguments[2]
        shift arguments
        shift arguments
        breaksw
      case '-i'
        shift arguments
        shift arguments
        breaksw
      case '--'
        shift arguments
        break
    endsw
  end
  set k = 1
  set params = ''
  while ( $k < $#arguments )
    set params = ($params $arguments[$k])
    @ k += 1
  end

# echo gigrs_finishframe $sapath $rmmach $project $params >> ${logfile}
  gigrs_finishframe $sapath $rmmach $project $params

else

  shift argv

  set k = 1
  set params = ''
  while ( $k < $#argv )
    set params = ($params $argv[$k])
    @ k += 1
  end

# echo gigrs_anibatch $sapath $rmmach $params >> ${logfile}
  gigrs_anibatch $sapath $rmmach $params

endif
