1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
read EXPEDITEUR <<<$(awk -F "[<> ]" '/^From:/ {print $(NF-1)} ' ${SAVAGE_HOME}/fichiers/SAV_AGENCE__91bc915d93b2803546aaf344ace9527cc9e3c06f5b7a1d2b19adeaf02893d01b.txt)
DESTINATAIRE=$(awk 'BEGIN {FS = ":"; varTo = ""; flag = 0;}
$1 == "Subject" {flag=0;}
flag == 1 {vPdeb=index($0,"<");vPfin=index($0,">"); varTo = varTo ";" substr($0,vPdeb+1,vPfin-vPdeb-1) ";";}
$1 == "To" {vPdeb=index($0,"<");vPfin=index($0,">"); varTo = substr($0,vPdeb+1,vPfin-vPdeb-1); flag=1;}
END {print varTo;}' ${SAVAGE_HOME}/fichiers/SAV_AGENCE__91bc915d93b2803546aaf344ace9527cc9e3c06f5b7a1d2b19adeaf02893d01b.txt)
DATE_ENVOI=$(awk 'BEGIN {FS = ":"; varDate = ""; flag = 0; vPdeb=0; vPfin=0;}
$1 == "Date" {vPdeb=index($0,",")+1;vPfin=index($0,"+")-1; varDate = substr($0,vPdeb+1,vPfin-vPdeb-1);}
END {print varDate;}' ${SAVAGE_HOME}/fichiers/SAV_AGENCE__91bc915d93b2803546aaf344ace9527cc9e3c06f5b7a1d2b19adeaf02893d01b.txt)
#END {print sprintf("export DATE_ENVOI=\"%s\"",varDate);}' ${SAVAGE_HOME}/fichiers/SAV_AGENCE__91bc915d93b2803546aaf344ace9527cc9e3c06f5b7a1d2b19adeaf02893d01b.txt)
#eval "$DATE_ENVOI"
# == Reformatage de la date
#DATE_ENVOI=$(DATE_ENVOI -d "+%d %m %Y")
DATE_ENVOI=$(date --date="$DATE_ENVOI" +"%d/%m/%Y %H:%M:%S")
echo "EXPEDITEUR=${EXPEDITEUR}"
echo "DESTINATAIRE=${DESTINATAIRE}"
echo "DATE_ENVOI=${DATE_ENVOI}"
# == Intégration des variables dans table Oracle
echo "--Mise à jour de la table Oracle";
sqlplus -S ${SAVAGE_CONNECT} <<!!
set linesize 160
set pagesize 0
set feedback off
set termout off
set verify off
set echo off
set heading off
insert into SAVAGE_MAIL (EXPEDITEUR, DESTINATAIRE, DATE_ENVOI)
values ('${EXPEDITEUR}','${DESTINATAIRE}',to_date('${DATE_ENVOI}', 'DD/MM/YYYY HH24:MI:SS')); |
Partager