日期:2014-05-16  浏览次数:20624 次

谁能帮忙改一下shell脚本 ftp改成scp的模式
#!/bin/bash
hostip="192.168.1.108"
un="root"            #ftp账户
fw="123"  #ftp密码
local_dir="/home/ango/images/"  #本地路径
f_dir="/home/ango/images/"   #远程路径
cd $local_dir               #进入本地目录
while true;do               #开始循环
filegif=(`ls | sed -n '1p'`)    #截取目录下一个文件名
if [ -z $filegif ];then             #截取的变量是否存在,不存在继续循环。\
        sleep 1
        continue
fi
ftp -i -n -v $hostip <<EOF
user $un $fw
bin
cd $f_dir
put $filegif
quit
EOF
rm -f $filegif && sleep 1   #如果删除成功在传送下一个文件。
done

------解决方案--------------------
#!/bin/bash
hostip="192.168.1.108"
un="root"            #ftp账户
fw="123"  #ftp密码
local_dir="/home/ango/images/"  #本地路径
f_dir="/home/ango/images/"   #远程路径
cd $local_dir               #进入本地目录
while true;do               #开始循环
    filegif=(`ls 
------解决方案--------------------
 sed -n '1p'`)    #截取目录下一个文件名
    if [ -z $filegif ];then             #截取的变量是否存在,不存在继续循环。\
        sleep 1
        continue
    fi
    scp $filegif $un@$hostip:$f_dir
    rm -f $filegif && sleep 1   #如果删除成功在传送下一个文件。
done