#!/usr/bin/expect
set timeout 10
set host "IP地址"
set username "username"
set password "password"
set path "需要拷贝的文件路径"
set pathlocal "本地文件路径"
spawn scp $username@$host:$path $pathlocal
expect {
"(yes/no)?"
{
send "yes\n"
expect "*password:" { send "$password\n"}
}
"*password:"
{
send "$password\n"
}
}
expect "100%"
expect eof
网友评论