#!/bin/bash
#定义变量
if [ -z "$1" ]
then
forTimes=3
else
forTimes=$1;
fi
phpServerDir="/var/www/highchart/server/server.php"
host="192.168.2.61"
#开始循环重启
for((i=1;i <= $forTimes;i++))
do
((nowSsh=100+i))
/usr/bin/expect <<-EOF
spawn ssh -p "${nowSsh}22" "root@${host}" pkill php
expect {
"*yes/no*" { send "yes\r" }
"*password:*" { send "q12345t\r" }
}
interact
expect eof
EOF
sleep 0.5
/usr/bin/expect <<-EOF
spawn ssh -p "${nowSsh}22" "root@${host}" /usr/local/php/bin/php "${phpServerDir}"
expect {
"*yes/no*" { send "yes\r" }
"*password:*" { send "q12345t\r" }
}
interact
expect eof
EOF
sleep 1.5
done
#定义变量
if [ -z "$1" ]
then
forTimes=3
else
forTimes=$1;
fi
phpServerDir="/var/www/highchart/server/server.php"
host="192.168.2.61"
#开始循环重启
for((i=1;i <= $forTimes;i++))
do
((nowSsh=100+i))
/usr/bin/expect <<-EOF
spawn ssh -p "${nowSsh}22" "root@${host}" pkill php
expect {
"*yes/no*" { send "yes\r" }
"*password:*" { send "q12345t\r" }
}
interact
expect eof
EOF
sleep 0.5
/usr/bin/expect <<-EOF
spawn ssh -p "${nowSsh}22" "root@${host}" /usr/local/php/bin/php "${phpServerDir}"
expect {
"*yes/no*" { send "yes\r" }
"*password:*" { send "q12345t\r" }
}
interact
expect eof
EOF
sleep 1.5
done