- 论坛徽章:
- 0
|
#!/bin/sh
#itTangzeng
#test mutual trust
usage="usage 0 ips(ip1,ip2)"
ips=$1
if [ "$ips" = "" ]
then
echo $usage
exit 1
fi
splitStringToArray()
{
if [ $# -eq 1 ]
then
l_splitChar=" "
elif [ $# -eq 2 ]
then
l_splitChar="${2}"
else
echo " arameter($*) error.Usage:splitStringToArray string split_char!"
return 1
fi
local l_string="${1}"
for str in `echo $l_string | awk -v ch="${l_splitChar}" '{ nCount=split($0,myarr,ch); for(i=1;i<=nCount;i++) { print myarr[i]} }'`
do
echo "${str}"
done
}
#test result
for out in `splitStringToArray $ips ","`
do
for in in `splitStringToArray $ips ","`
do
if [ "$in" != "" ]
then
echo -e "\n \033[0;33;1m ${out} -> ${in} \033[0m"
ssh -t $in "ssh -t $out 'date && exit 0' && date && exit 0"
fi
done
done |
|