for ip in${slaves_array[*]} do if [ "$cmd_type" = "remote" ]; then cmd=$2 ssh root@$ip"$cmd" elif [ "$cmd_type" = "scp" ]; then file=$2 if [ -d $file ]; then scp -r $file root@$ip:$file else scp $file root@$ip:$file fi fi done echo"Commands Executed!"