Script Ftp put file and backup after put file and check file put success in linux

Опубликовано: 31 Июль 2017
на канале: Phuong Nguyen
1,196
8

Hi everyone,
This tutorial i introduce write script ftp send file in bash script linux and write log
success and count file sent to ftp sever.

#!/bin/bash
DIR="/root/opt/ftp/ftpUpload"
DEST="/root/opt/ftp/backup"
FTPLOG=/root/opt/ftp/log
day=`/bin/date +%Y-%m-%d`
file="ftp_$day.txt"

HOST="x.y.z.t"
USER="user"
PASSWD="password"
DATE=`date +%F_%H:%M:%S`;

cd $DIR
sleep 1
FILE=`ls -t *.txt| head -1`

ftp -n -v $HOST END | tee /root/opt/ftp/temp.txt
user $USER $PASSWD
put $FILE
END

Search=$FILE
FileToSearch="/root/opt/ftp/temp.txt"
if grep $Search $FileToSearch; then
echo $DATE $FTPLOG/$file
echo "$FILE send OK"
cat /root/opt/ftp/temp.txt $FTPLOG/$file
mv $FILE $DEST
count=`cat $FTPLOG/$file | grep -e "closing data" | wc -l`
echo "Count File sent is:"$count $FTPLOG/$file
else
echo "$FILE sent Fail!."
fi

Thanks for watching this video


Смотрите видео Script Ftp put file and backup after put file and check file put success in linux онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Phuong Nguyen 31 Июль 2017, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,196 раз и оно понравилось 8 людям.