1. 免密码,不同linux机器下文件的拷贝

#!/usr/bin/expect

set timeout 300

spawn scp a.txt root@10.91.10.90:/home/test/

expect {
		"*(yes/no)?" {
                        send "yes\r"
                        expect "*assword:"
                        send "root123\r"
                    }
        "*assword:"   {send "root123\r"}
 }
 expect "*#"

1.上述代码中,设置延时3s

2将a.txt文件从当前目录下拷贝至10.91.10.90机器下的/home/test/目录下,用户名是root,密码是root123.