运行 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