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, duration hours minute second in high quality that is uploaded to the channel Phuong Nguyen 31 July 2017. Share the link to the video on social media so that your subscribers and friends will also watch this video. This video clip has been viewed 1,196 times and liked it 8 visitors.