您的位置:首页 > 其它

expect实现多台服务器自动巡检

2014-05-23 09:37 218 查看
#!/usr/bin/expect -f

#=====================================================#

#                   monitor.exp                                                                                    #

#             written by dongxiaobing                                                                     #

#                   2014.05.22                                                                                     #

#  具有相同的用户名和密码的多台服务器自动巡检                                       #

#            monitor.sh为智能巡检脚本                                                                  #

#                                                                                                                             #

#                                                                                                                              #

#======================================================#

foreach ip { 

192.168.1.108

192.168.1.109

} {

spawn ssh idnms@$ip

expect {

"*yes/no" {send "yes\r";exp_continue}

"*password:" {send "kindsoft\r"}

}

expect "$*"

send "./monitor.sh\r"

send "exit\r"

expect eof

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: