#!/usr/bin/expect -f
#Author by Jack 
#date is 2016-07-15

set password 7oeYePuGytdMVmEV     #设置awstats服务器的密码

set date [exec date +%Y%m%d]        #设置时间的方式,今天的时间
#set date [exec date -d "yesterday" +%Y%m%d]    #设置昨天的时间

#upload remote host
spawn /usr/bin/scp -r /logs/nginx/awstatslog/access_log${date}app-nginx1 sysadmin@10.10.10.49:/tmp    
set timeout 3
expect {
"yes/no" {send "yes\r";exp_continue}
}
expect "sysadmin@10.10.10.49's password:"    
set timeout 3
send "$password\r"
set timeout 300
send "exit\r"
expect eof