首页 > 其他 > 详细

expect使用demo

时间:2015-08-06 20:01:26      阅读:281      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!