lpz_sap_m3_run_12.sh

#!/bin/sh
# Parametre 1 : environnement sur lequel seront chargees les donnees
# Parametre 2 : nom du fichier utilise pour l'initialisation du refentiel ou "integration" pour le mode normal (apres une initialisation.
# exemple de nom de fichier : LPZ_SAPM3_210510_1.zip (le fichier doit se trouver dans le repertoire : ftp.faiveley.com/LpzXM3/input)
echo "Environnement : "${1}
echo "Mode d'execution : "${2}
echo ""
# Sauvegarde des fichiers avant traitement
dt_dir=`date +"%Y_%m_%d_%H%M%S"`
dir_save=sauve_av_traitement_$dt_dir
cd /data/talend/repository/${1}
mkdir $dir_save
cp *.* $dir_save
sleep 5
sh /data/talend/jobs/LPZ_SAP_M3_INTEGRATION_1.2/LPZ_SAP_M3_INTEGRATION/LPZ_SAP_M3_INTEGRATION_run.sh ${1} ${2}
err_sh=$?
echo "Valeur err_sh : "$err_sh
echo ""
dt_fin=`date +"%A %d/%m/%Y - %H:%M:%S"`
echo $dt_fin
echo ""
if [ $err_sh -eq 0 ] ; then
${ABM_BIN}/tmail -c ${ABM_BIN}/tmail.ini -to ${3} -sub "DCC : Integration SAP - M3 env: ${1} - OK" -msg "
----------------------------- VTOM MESSAGE OK ---------------------------------------
The scheduler Vtom has successfully completed the process of Talend integration of SAP-LPZ data in M3 (${1}).
Please verify log file you received from Talend for any functional failure.
Best Regards.
------------------------------ END OF VTOM MESSAGE -----------------------------------------" -att $TOM_LOG.o\;$TOM_LOG.e
else
${ABM_BIN}/tmail -c ${ABM_BIN}/tmail.ini -to ${3} -cc ${4} -sub "ERROR - Integration SAP - M3 env: ${1} - ERROR" -msg "
******************* VTOM MESSAGE ERROR ***********************
The scheduler Vtom has completed with error the process of Talend integration of SAP-LPZ data in M3 (${1}).
Please verify log file you received from Talend for any functional failure.
Best Regards.
******************* END OF VTOM MESSAGE ERROR***********************" -att $TOM_LOG.o\;$TOM_LOG.e
err_sh=1
fi
exit $err_sh

chk_fic_sap_m3_new.sh

#!/bin/sh -vx

date_fic=`date +%d%m%y`
echo « date : « $date_fic
echo «  »

nom_fic= »LPZ_SAPM3_ »$date_fic »_1.zip »
echo « nom du fichier : « $nom_fic
echo «  »
cd /exploit/scripts

HOST=’filetransfert.faiveleytransport.com’
PORT=’21’
USER=’$1′
PASSWD=’$2′

ftp -i -n $HOST $PORT << END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd lpzxm3
cd In
bin
get $nom_fic
quit
END_SCRIPT

test -s $nom_fic
fic=$?
if [ $fic -eq 0 ] ; then
${ABM_BIN}/tmail -c ${ABM_BIN}/tmail.ini -to ${1} -sub « DCC : SAP file on filetransfert.faiveleytransport.com OK » -msg  »
Dear Dietmar,

Your file $nom_fic is now on our ftp server : filetransfert.faiveleytransport.com.

Best Regards.
IT Faiveley Team »

rm $nom_fic

else
${ABM_BIN}/tmail -c ${ABM_BIN}/tmail.ini -to ${1} -cc ccosupport@faiveley-test.com -sub « ERROR : SAP file on filetransfert.faiveleytransport.com NOT OK » -msg  »
Dear Dietmar,

We have not received your file from SAP on our ftp server (filetransfert.faiveleytransport.com) or the file is empty, today.

Best Regards.
IT Faiveley Team »;
fi

exit $fic

backup_des_fichiers.sh

# Récupération des fichiers avant traitement
echo Environnement : ${1}
echo Dossier de sauvegarde : ${2}

echo Contenu du dossier /data/talend/repository/${1} avant effacement
cd /data/talend/repository/${1}
ls -ltra
# Cette commande ne supprime pas les sous dossier
rm *.*
echo Contenu du dossier de sauvegarde /data/talend/repository/${1}/${2}
cd /data/talend/repository/${1}/${2}
ls -ltra
cp *.* ..
echo Contenu du dossier /data/talend/repository/${1} après récupération
cd ..
ls -ltra