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

Published: 31 July 2017
on channel: 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


Watch video Script Ftp put file and backup after put file and check file put success in linux online without registration, duration hours minute second in high quality. This video was added by user Phuong Nguyen 31 July 2017, don't forget to share it with your friends and acquaintances, it has been viewed on our site 1,196 once and liked it 8 people.