日期:2014-05-16 浏览次数:20629 次
#/!bin/sh
#author: wxh
#ip
ip="192.168.1.100"
#服务器账号
user="root"
#服务器密码
pwd="ALEX885901"
#源文件地址
src_file=/home/log/apache/logs/access."+%Y_%m_%d".log
#本地文件地址
dest_file=/home/log/
spawn scp $user@$ip:$src_file $dest_file
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" { send "$pwd\n"}
}
"*assword:"
{
send "$pwd\n"
}
}
expect eof
spawn scp $user@$ip:$src_file $dest_file
expect {
"*yes*"
{
send "yes\n"
expect "*assword*" { send "$pwd\n"}
}
"*assword*"
{
send "$pwd\n"
}
}
send "exit\r"
expect eof