运行 scp 的脚本

#!/usr/bin/expect
set timeout 10
set host [lindex $argv 0]
set username root
set password admin
set src_file [lindex $argv 1]
set dest_file [lindex $argv 2]
spawn scp $username@$host:$src_file $dest_file
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" { send "$password\n"}
}
"*assword:"
{
send "$password\n"
}
}
expect "100%"
expect eof

 

posted on 2015-02-11 08:08  lion382  阅读(279)  评论(0编辑  收藏  举报