Erreur scrpit shell : fin de fichier prématuré.

Résolu
Lacapricorne Messages postés 17 Date d'inscription   Statut Membre Dernière intervention   -  
Lacapricorne Messages postés 17 Date d'inscription   Statut Membre Dernière intervention   -
Bonjour,
Je suis assez débutante en script shell.
J'ai un script shell qui, d'abord exporte les données de la base de données mysql vers fichier.csv puis comprèsse ce fichier et enfin l'envoi vers un autre serveur dont l'adresse IP est 192.168.56.103.

Voici mon code :



#!/bin/sh
currentTimeStartExp=`date +'20%y-%m-%d %H:%M:%S'`
#currentfile="/data/barring/cdr_rated_$1"+".csv"
#currentfile="/data/tmp/cdr_rated_$1.csv"
#currentfile="/DWH2017/SAVE/Reste/cdr_rated_$1"+".csv"
if [ $# -eq 0 ]
then
    currentfile="/archives/export_base/export_"`date +'20%y-%m-%d' -d '-1 day'`".csv"
    currentdate=`date +'20%y-%m-%d' -d '-1 day'`
else
    currentfile="/archives/export_base/export_$1.csv"
    currentdate=$1
fi
echo "Start EXPORT $currentfile at $currentTimeStartExp"
#Declaring mysql BIG5 DB connection 
DBIG_MASTER_DB_USER='root'
DBIG_MASTER_DB_PASSWD=''
DBIG_MASTER_DB_PORT=3306
DBIG_MASTER_DB_HOST='192.168.56.102'
DBIG_MASTER_DB_NAME='bdorange'

#mysql command to connect to database prod
/usr/bin/mysql -u$DBIG_MASTER_DB_USER -p$DBIG_MASTER_DB_PASSWD -P$DBIG_MASTER_DB_PORT -h$DBIG_MASTER_DB_HOST -D$DBIG_MASTER_DB_NAME <<EOF
select * from $DBIG_MASTER_DB_NAME.affecter where iddate between '$currentdate' and '$currentdate 23:59:59' into outfile '$currentfile' fields terminated by '|';
EOF
#currentTimeEndExp=`date +'20%y-%m-%d %H:%M:%S'`
if [ -f "$currentfile" ]
then
 currentfilegz="$currentfile.gz"
 gzip $currentfile
 if [ -f "$currentfilegz" ]
 then

  sshpass -p "rasoamanarivo" ssh root@192.168.56.102<<EOF
         sshpass -p "rasoamanarivo" scp -p -r root@192.168.56.103:$currentfilegz /DWHFB/archivecsvprod
EOF
         echo  "FTP :$currentfilegz OK ."
  currentTimeEndExp=`date +'20%y-%m-%d %H:%M:%S'`
  echo "End EXPORT $currentfilegz at $currentTimeEndExp"
  rm -rf $currentfilegz
 fi

fi





Mais voilà, quand j’exécute mon script il retourne toujours l'erreur : " ligne44: Erreur de syntaxe : fin de fichier prématurée"
J'essai de trouver ou se trouve exactement l'erreur mais je n'y arrive pas. Est ce que quelqu'un peut m'aider s'il vous plait, je sais plus du tout quoi faire.Merci beaucoup.
A voir également:

1 réponse

UnGnU Messages postés 1158 Date d'inscription   Statut Contributeur Dernière intervention   158
 
Salut,

Le script a été écrit sous GNU/Linux ou sous Windows ?

0
Lacapricorne Messages postés 17 Date d'inscription   Statut Membre Dernière intervention  
 
Il a été écrit et exécuté sous GNU/Linux.
0
UnGnU Messages postés 1158 Date d'inscription   Statut Contributeur Dernière intervention   158 > Lacapricorne Messages postés 17 Date d'inscription   Statut Membre Dernière intervention  
 
Ok, tu peux afficher le contenu avec cat -A s'il te plaît ?
0