手机
当前位置:查字典教程网 >脚本专栏 >linuxshell >expect自动检测并重启另外一台服务器上的程序代码
expect自动检测并重启另外一台服务器上的程序代码
摘要:[s005you]#cathaproxy_expect复制代码代码如下:#!/usr/bin/expectsetssh_user"fivet...

[s005 you] # cat haproxy_expect

复制代码 代码如下:

#!/usr/bin/expect

set ssh_user "fivetrees"

set password "123456"

spawn ssh -i /root/.ssh/$ssh_user Server004.xd.com

expect_before "no)?" {

send "yesr" }

sleep 0.5

expect "Enter passphrase for key*"

send "$passwordr"

expect "*#"

send "/tmp/haproxy.shr"

expect "*#"

send "echor"

exit

[s004 him] # cat haproxy.sh

复制代码 代码如下:

#!/bin/bash

Thread=`ps -ef | grep haproxy | grep -v haproxy.sh | grep -v grep`

if [ -z "$Thread" ]

then

/tmp/haproxy_expect

fi

[s004 him] # cat haproxy_expect

复制代码 代码如下:

#!/usr/bin/expect

set ssh_user "fivetrees"

set password "123456"

spawn ssh -i /root/.ssh/$ssh_user Server005.xd.com

expect_before "no)?" {

send "yesr" }

sleep 0.5

expect "Enter passphrase for key*"

send "$passwordr"

expect "*#"

send "/usr/local/haproxy/sbin/haproxy -f /usr/local/haproxy/haproxy.cfgr"

expect "*#"

send "echor"

exit

【expect自动检测并重启另外一台服务器上的程序代码】相关文章:

shell脚本函数:控制颜色、定位、居中显示的代码

Shell脚本调快调慢系统时间(测试服务器时使用)

Shell脚本中调用、引用、包含另外一个脚本文件的两种方法

Shell脚本实现自动检测修改最快的Ubuntu软件源

linux服务器安全加固shell脚本代码

shell脚本编写的俄罗斯方块游戏代码

比较两个字符串是否相等的shell代码

智能监测自动重启Apache服务器的Shell脚本

自动化下载并检测ftp文件备份的shell脚本

Shell脚本实现的一个简易Web服务器例子分享

精品推荐
分类导航