码迷,mamicode.com
首页 > 其他好文 > 详细

expect使用demo

时间:2015-08-06 20:02:33      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

#!/usr/bin/expect
set timeout 30
set ip [lindex $argv 0]
spawn ssh root@$ip
 
expect {
"yes/no" { send "yes\r"; exp_continue }
"password:" { send "123456\r" }
}

expect "#"
send "sed -e ‘1,1000s/dns-search/#dns-search/‘ /etc/network/interfaces > /etc/network/test \r"

expect "#"
send "mv -f /etc/network/test /etc/network/interfaces \r"

expect "#"
send "/etc/init.d/networking restart \r"
 
expect "#"
send "exit\r"

 

expect使用demo

标签:

原文地址:http://www.cnblogs.com/sayaoailun/p/4708763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!