命令格式: tt <group|key> <command>
eg: tt crmexe pwd
tt crmexe 'find . -name "*.log"'
tt crmexe 'find . -name "*.sh"|sh'
more tt
#!/bin/sh
if [ $# -lt 2 ];thenecho "Please input ARGV key :
tt <Group|ip> [p|P] <CMD>
Group: crmexe webexe
or IP:xxx.xxx.xxx.xxx
CMD
[p|P]: add first 'ps -ef|grep -v grep '
"
exit 1
fi
#默认passwd
passwd="123"
if [ "$2" = "p" -o "$2" = "P" ]
then
cmd="ps -ef|grep -v grep|grep $3"
else
cmd=$2
fi
grep -w $1 ${HOME}/sbin/data.dat|while read grp name l_passwd
do
if [ -z "$grp$name" ]
then
echo $1
continue
fi
if [ -z $l_passwd ]
then
l_passwd=$passwd
fi
echo "------------------------ GROUP:$grp Name: $name ------------------------"
${HOME}/sbin/sshpass -p $l_passwd ssh -n $name -o StrictHostKeyChecking=no $cmd
done
data.dat 配置文件 :
crmexe crm@192.168.168.11
crmexe crm@192.168.168.12
webexe crm@192.168.168.13 456