linux下tftp自动传输指定后缀文件并删除

因为项目需要,自己写的一个检测当前目录下是否存在指定后缀名的文件,若有,则通过tftp命令依次将所有文件传输到指定tftp服务器,成功后删除对应文件(空间有限)

    #!/bin/sh

    fcounts=`ls -l|grep "^-"|grep .bin|wc -l`
    echo ${fcounts}
    if [ "${fcounts}" -gt 0 ];then
        fb=`find ./ -name '*.bin'`
        res=1
        for fc in ${fb}
        do
            tftp -l "${fc}" -p 192.168.1.111
            res=$?
            echo "${res}"
            if [ "${res}" -eq 0 ];then
                rm "$fc"
                echo " transfor success!"
                else
                echo " transfor failed!"
            fi
        res=1
        done
    fi

猜你喜欢

转载自blog.csdn.net/yanlutian/article/details/82669107