#!/bin/bash
user=root
passwd=123qwe
cat /dev/null > r1.txt
cat /dev/null > r2.txt
if [[ "$1" = "--help" ]];then
echo "variables:mysql variables;null:all variables;"
exit 1
elif [[ "$1" != "" ]];then
echo $1 $2 $3 > temp.txt
var=`awk -F"[ :]+" '{print $5}' temp.txt`
h1=`awk -F"[ :]+" '{print $1}' temp.txt`
p1=`awk -F"[ :]+" '{print $2}' temp.txt`
h2=`awk -F"[ :]+" '{print $3}' temp.txt`
p2=`awk -F"[ :]+" '{print $4}' temp.txt`
echo $h1 $p1 $h2 $p2
result1=`mysql -u${root} -p${passwd} -h${h1} -P${p1} -e "select * from information_schema.global_variables;" | grep -i $var | awk '{print $2}'`
result2=`mysql -u${root} -p${passwd} -h${h2} -P${p2} -e "select * from information_schema.global_variables;" | grep -i $var | awk '{print $2}'`
echo $var : $result1 > r1.txt
echo $var : $result2 > r2.txt
diff r1.txt r2.txt -y -W 150
elif [ "$1" = "" ];then
`mysql -u${root} -p${passwd} -hlocalhost -P3306 -e "select * from information_schema.global_variablesG" > r1.txt`
`mysql -u${root} -p${passwd} -hlocalhost -P3306 -e "select * from information_schema.global_variablesG" > r2.txt`
#echo $result1 > r1.txt
#echo $result2 > r2.txt
diff r1.txt r2.txt -y -W 150
echo "if different#############################"
diff r1.txt r2.txt
else
echo error
fi
脚本弱 写的简单~~
阅读(1640) | 评论(0) | 转发(0) |