linux下使用ftp传递文件的shell脚本

使用ftp传递文件,传递过程中防止对方取文件,后缀名为writing,传完后再改回来。

#!/bin/bash

dstpath=cnet
ftpip="127.0.0.1"
login="user pwd"
#cirtime=3
filepath=/home/data/out
#filtercount=$(ls $filepath/out/*.txt|wc -l)

ftptransfer()
{
        filename=$1
        #echo $filename
        ftp -i -n ${ftpip} << EOF
        user ${login}
        #mkdir $dstpath
        cd $dstpath
        bin
        send ${filename} ${filename}.writing
        rename ${filename}.writing ${filename}
        quit    
EOF

}

cd $filepath
files=`ls *.txt`
for f in $files
do
        #echo $f
        ftptransfer $f
        rm -f $f
done
exit 0

 

你可能感兴趣的:(shell脚本)