标签:set break $? success pre pen bre roo echo
#!/bin/bash #----------------------------------- #Author: panb ##此脚本用来向openresty服务器执行命令 #----------------------------------- set -e Usage(){ echo "Usage: $0 host1 host2 ... ‘command‘" } if [ $# -lt 2 ];then Usage exit 0 else cmd=${!#} fi i=1 success=0 failed=0 for ip in $@;do if [ $i -eq $# ];then break fi ssh -i ops-ibox.pem root@$ip "$cmd" if [ $? -eq 0 ];then success=$(($success+1)) echo -e "\n\033[32m$ip | success \033[0m \n" #cat $logfile else ((failed++)) 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 ‘-------------------------‘
标签:set break $? success pre pen bre roo echo
原文地址:https://www.cnblogs.com/jcici/p/13140783.html