#!/bin/bash path=/opt/portmonitor/ logfile=/var/log/portmon fulltext=(`cat $path/ipbase.txt`) check=(`cat $path/count.txt`) rm $path/count.txt a=0 b=`expr $a + 1` e=`expr $b + 1` while [ ${fulltext[$a]} ] do send=(${fulltext[$a]}":"${fulltext[$b]}"-"'not answer 3 time') elem=("${fulltext[$a]}"\ "${fulltext[$b]}") ################subroutines#################################### bad (){ if [ "${check[$e]}" -lt "2" ];then zap[$i]=$elem ((check[$e]++)) #echo 'schetchik +:'${check[$e]} echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` elif [ "${check[$e]}" -eq "2" ];then zap[$i]=$elem ((check[$e]++)) echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" echo "`date` $send" >>$logfile ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` else zap[$i]=$elem echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` fi } good () { zap[$i]=$elem check[$e]=0 echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` } #################endsubroutines#################################### nc -w2 -z ${fulltext[$a]} ${fulltext[$b]} && good || bad done
#!/bin/bash path=/opt/portmonitor/ logfile=/var/log/portmon fulltext=(`cat $path/ipbase.txt`) check=(`cat $path/count.txt`) rm $path/count.txt a=0 b=`expr $a + 1` e=`expr $b + 1` while [ ${fulltext[$a]} ] do send=(${fulltext[$a]}":"${fulltext[$b]}"-"'not answer 3 time') elem=("${fulltext[$a]}"\ "${fulltext[$b]}") ################subroutines#################################### bad (){ if [ "${check[$e]}" -lt "2" ];then zap[$i]=$elem ((check[$e]++)) #echo 'schetchik +:'${check[$e]} echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` elif [ "${check[$e]}" -eq "2" ];then zap[$i]=$elem ((check[$e]++)) echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" gsmsendsms -d /dev/ttyACM0 +79xxxxxxxxx "$send" echo "`date` $send" >>$logfile ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` else zap[$i]=$elem echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` fi } good () { zap[$i]=$elem check[$e]=0 echo "${zap[$i]}"\ "${check[$e]}">>$path/count.txt ((i++)) a=`expr $a + 3` b=`expr $b + 3` e=`expr $e + 3` } #################endsubroutines#################################### nc -w2 -z ${fulltext[$a]} ${fulltext[$b]} && good || bad done
Source: https://habr.com/ru/post/132244/
All Articles