shell, 压缩文件ftp上传到远端

上一篇 / 下一篇  2013-05-17 15:39:21 / 个人分类:Linux Shell

先贴脚本:
#! /usr/local/bin/bash
# put local file to remote dir.

FTP_HOST=192.168.23.94
FTP_USER=root
FTP_PASS=root
echo "please input the dir where you want put"
read DIR
if [ ! -d $DIR ]
then
        echo "the dir is not exist, please confirm it"
else
        cd $DIR
        ls -l
        echo "please choice the file which you want put."
        read FILE
        NAME="$FILE""_"`date +%Y%m%d%H%M%S`
        tar cvf "$NAME"".tar" $FILE
        gzip "$NAME"".tar"

ftp -i -n $FTP_HOST <<EOF
user $FTP_USER $FTP_PASS
cd /export/home/willdu/sql-dir
put "$NAME"".tar.gz"
bye
EOF

rm "$NAME"".tar.gz"
fi

TAG:

 

评分:0

我来说两句

Open Toolbar