[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
暂无评论内容