标签:nbsp 环境 usr eof expec pass 才有 dha 连接
环境: redhat 6.5
网上测试了很多写法都不成功,测试了很久才有了一下脚本。
命令远程连接ssh并执行命令,scp/ftp等远程连接操作同理
#!/usr/bin/expect
set passwd "password"
set user "root"
set host "192.168.1.168"
spawn ssh $user@$host
#expect "yes/no"
#send "yes\r"
expect "password"
send "$passwd\r"
expect "$user@"
send "echo ‘passwd‘ >> /root/for_test.sh\r"
expect "$user@"
send "exit\r"
expect eof
标签:nbsp 环境 usr eof expec pass 才有 dha 连接
原文地址:http://www.cnblogs.com/manug/p/7979277.html