企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#!/bin/bash #set -e Usage(){ echo "Usage:$0 host1 host2 ... 'command'" } if [ $# -lt 2 ];then Usage exit 0 else cmd=${!#} fi cmd=df logfile=$(mktemp) i=1 success=0 failed=0 echo $@ for ip in $@;do if [ $i -eq $# ];then break fi ssh $ip $cmd &> $logfile if [ $? -eq 0 ];then success=$(($success+1)) echo -e "\n\033[32m$ip | success \033[0m \n" cat $logfile else failed=$((failed+1)) echo -e "\n\033[31m$ip | failed \033[0m\n" cat $logfile fi ((i++)) done echo -e '\n-------------------' echo -e "\033[32msuccess: $success |failed : $failed \033[0m" echo -e '----------------'