#!/bin/ksh
#**********************************************************************#
#*                                                                    *#
#* Copyright (c) 2001 by Sun Microsystems, Inc.                       *#
#* All rights reserved.                                               *#
#*                                                                    *#
#**********************************************************************#


########################################################################
#                                                                      #
# EBM BATCH JOB MACRO :     IEBGENER                                   #
# Purpose             :     Copy utility                               #
#                                                                      #
########################################################################

if [ $VALIDATE = 'y' ]
then
#---------------
#VALIDATION MODE
#---------------
   echo PGM=$0 in validation mode is not executed:
   DD_SYSUT1=`ebmsed $DD_SYSUT1`
   DD_SYSUT2=`ebmsed $DD_SYSUT2`
   if [ -z "$DD_SYSUT1" ]
   then
     echo SYSUT1 not defined
   fi
   if [ -z "$DD_SYSUT2" ]
   then
     echo SYSUT2 not defined
   fi
   env | grep 'DD_SYSUT[0-9]*=' | while read line
   do
     echo $line
   done
else
   #---------------
   #COPY FILE(S)    
   #---------------
   DD_SYSUT1=`ebmsed $DD_SYSUT1`
   DD_SYSUT2=`ebmsed $DD_SYSUT2`
   if [ -z "$DD_SYSUT1" ]
   then
     echo SYSUT1 not defined
     echo 1 > status.${JON}
     exit 1
   fi
   if [ -z "$DD_SYSUT2" ]
   then
     echo SYSUT2 not defined
     echo 1 > status.${JON}
     exit 1
   fi
echo " "
   env | grep 'DD_SYSUT[0-9]*=' | sed -e 's/=/ /' | while read line
   do
     set $line
     if [ $1 = DD_SYSUT1 ]
     then
        continue
     fi
     cat `ebmsed $DD_SYSUT1 splitconcpaths` > $2
     if [ $? -ne 0 ]
     then
       echo `basename $0` ": ABORTED "
       echo 1 > status.${JON}
       exit 1
     else
       echo "IEBGENER (I) Copy completed Input:"
       echo "             $DD_SYSUT1 Output: $2"
       echo " "
     fi
   done
fi
echo 0 > status.${JON}
exit 0
