#------------------------------------------------------------------
# Obtencion de fecha y hora actuales
#------------------------------------------------------------------
DATE="`date +%Y%m%d`"
TIME="`date +%H%M%S`"

#------------------------------------------------------------------
# Inicializar variables
#------------------------------------------------------------------
# Directorio para los logs
DIR_LOGS=/datos/ab03b/log

# Nombre fichero log
NOMBRE_FICHERO_LOGS=Ab03bArchivoExpedientes
FICHERO_LOGS=$DIR_LOGS/$NOMBRE_FICHERO_LOGS`date '+%d_%m_%Y'`.log

# Directorio desde donde se ejecuta
DIR_EJECUCION=/aplic/ab03b/cade
echo $DIR_EJECUCION

# Fichero que se ejecuta
CLASE_JAVA1=Ab03bArchivoExpedientes

# Directorio donde estan los diferentes java
DIR_CLASE_MAIN=ab03b.exe.batch

#------------------------------------------------------------------
# Fin Inicializar variables
#------------------------------------------------------------------

#---------------- inicio copiado -----------------------------

DIRAPLI=/aplic/ab03b; export DIRAPLI
DIRDATOS=/datos/ab03b; export DIRDATOS

AB03B=/aplic/ab03b/dist/ab03b.jar
SPRING=/aplic/ab03b/lib/n38n.jar:/aplic/ab03b/lib/n38i.jar:/aplic/ab03b/lib/spring-aop-3.1.2.RELEASE.jar:/aplic/ab03b/lib/aopalliance-1.0.jar:/aplic/ab03b/lib/n38c.jar:/aplic/ab03b/lib/n38a.jar:/aplic/ab03b/lib/javax.servlet_1.0.0.0_2-5.jar:/aplic/ab03b/lib/x38ShLibClasses-rss-2.4.4-RELEASE.jar:/aplic/ab03b/lib/x38ShLibClasses-pif-2.4.4-RELEASE.jar:/aplic/ab03b/lib/x38ShLibClasses-dav-2.4.4-RELEASE.jar:/aplic/ab03b/lib/x38ShLibClasses-2.4.4-RELEASE.jar:/aplic/ab03b/lib/spring-security-web-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-security-taglibs-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-security-core-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-security-config-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-security-acl-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-web-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-webmvc-3.1.2.RELEASE.jar:/aplic/ab03b/lib/commons-logging-1.1.1.jar:/aplic/ab03b/lib/spring-asm-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-expression-3.1.2.RELEASE.jar:/aplic/ab03b/lib/ojdbc14-10.2.jar:/aplic/ab03b/lib/spring-context-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-beans-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-core-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-jdbc-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-tx-3.1.2.RELEASE.jar:/aplic/ab03b/lib/spring-context-support-3.1.2.RELEASE.jar:/aplic/ab03b/lib/slf4j-api-1.6.6.jar:/aplic/ab03b/lib/rt.jar:/config/ab03b
#SPRING=/aplic/aa64/lib/spring.jar
#COMUNES=/usr/j2se/jakarta-struts-1.1/lib/commons-logging.jar
#Q70=/aplic/aa64/lib/q70.jar
#R01_IW=/aplic/aa64/lib/xalan-2.4.0.jar:/usr/j2se/jakarta-struts-1.1/lib/commons-beanutils.jar:/aplic/aa64/lib/javax.ejb.jar:/oracle1024/jdbc/lib/classes12.zip:/aplic/aa64/lib/jndi-1.2.1.jar:/aplic/aa64/lib/weblogic.jar

#LD_LIBRARY_PATH=/aplic/v90/lib:$LD_LIBRARY_PATH:/aplic/v90/lib:$LD_LIBRARY_PATH:/aplic/aa64/lib; export LD_LIBRARY_PATH

CLASSPATH_WL11=/config:/aplic/ab03b/dist/ab03b.jar:/oracle1024/jdbc/lib/ojdbc14.jar:/oracle1024/jdbc/lib/nls_charset12.jar;

CLASSPATH=$CLASSPATH_WL11:/$SPRING:/aplic/ab03b/lib; export CLASSPATH

#-------------fin copiado ----------------------------

STRING=" "
. n38bd 34919 01 STRING
 
#USUARIO=`echo $STRING | cut -d '#' -f2`
#PASSWORD=`echo $STRING | cut -d '#' -f3`

# ------------------------------------------------------------------

#------------------------------------------------------------------
# Lanzamiento del proceso
#------------------------------------------------------------------
echo "Lanzando el proceso. Espere unos segundos ..."

cd $DIR_EJECUCION

#$JAVA_HOME/bin/java -cp $CLASSPATH -d64 -Xms64M -Xmx1024M $DIR_CLASE_MAIN.$CLASE_JAVA1 "$USUARIO" "$PASSWORD">> $FICHERO_LOGS
$JAVA_HOME/bin/java -cp $CLASSPATH -d64 -Xms64M -Xmx1024M $DIR_CLASE_MAIN.$CLASE_JAVA1 
cSTATUS=${?}
 echo "Proceso clase java terminado. Resultado:$cSTATUS."

if [ $cSTATUS != 0 ]
then	
	echo "El proceso no ha finalizado correctamente"
	echo "Comprobar fichero de datos ($FICHERO_LOGS) para detectar errores"
    	exit 1
else
	echo "Proceso finalizado correctamente"	
    exit 0
fi

