建伟

导航

 
#!/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"

 

posted on 2015-08-06 18:08  建伟  阅读(207)  评论(0)    收藏  举报