[CentOS7]expect传参
set host [lindex $argv 0] 0代表第一个参数
#!/usr/bin/expect
#set passwd "12345678\n"
set timeout 20
# 外部传递参数
set host [lindex $argv 0]
spawn ssh-copy-id $host
expect {
"(yes/no)?"
{
send "yes\n"
expect "*assword:" { send "password\n"}
}
"*assword:"
{
send "password\n"
}
}
expect eof