60 lines
1.1 KiB
Bash
60 lines
1.1 KiB
Bash
#!/bin/ksh
|
|
#set -x
|
|
# Progetto: Gateway MNP
|
|
# Script: ftp_DPPS
|
|
# Descrizione: FTP dei file verso DPPS
|
|
# $1 $2 $3 $4
|
|
# Parametri: nome_file_locale host user password
|
|
|
|
# impostazione ambiente
|
|
THIS_PATH=`dirname $0`
|
|
. $THIS_PATH/setEnv.sh
|
|
|
|
adesso=$(date)
|
|
|
|
THIS=`basename $0`
|
|
LOG=$MNP_LOG_SCRIPT_HOME/$THIS.log
|
|
|
|
echo '*****' $adesso Eseguo ftp verso DPPS >> $LOG
|
|
|
|
# Elimina il percorso dal nome del file per ottenere il nome file remoto
|
|
remote=$(echo $1 | awk -F/ '{print $NF}')
|
|
|
|
# KIT200507
|
|
# inserisco un carattere nel CTR per evitare problemi di ftp di file con size = 0
|
|
[ -s $1 ] || (echo " ") >> $1
|
|
# KIT200507
|
|
|
|
# Esegui l'FTP
|
|
|
|
ftp -n > outFtp 2> errFtp <<PARAM
|
|
open $2
|
|
user $3 $4
|
|
put $1 $remote
|
|
bye
|
|
PARAM
|
|
|
|
|
|
# Controlla l'output del comando ftp per determinare se ci sono stati
|
|
# problemi
|
|
|
|
if [[ -s errFtp || -s outFtp ]]
|
|
then
|
|
echo Trasferimento errato per il file $1 >> $LOG
|
|
if [[ -s outFtp ]]
|
|
then
|
|
echo '---- outFtp: ' >> $LOG
|
|
cat outFtp >> $LOG
|
|
fi
|
|
|
|
if [[ -s errFtp ]]
|
|
then
|
|
echo '---- errFtp: ' >> $LOG
|
|
cat errFtp >> $LOG
|
|
fi
|
|
|
|
exit 1
|
|
else
|
|
echo File $1 trasferito con successo >> $LOG
|
|
exit 0
|
|
fi |