#!/bin/sh #latopen p=5 TbStat=(ESTABLISHED LISTEN SYN_SENT SYN_RECV FIN_WAIT1 FIN_WAIT2 TIME_WAIT CLOSE CLOSE_WAIT LAST_ACK CLOSING UNKNOWN) netstat -laputen 2>/dev/null | while read a b c d e f g h i ; do case $d in *.*.*) Ltb=0 while [ $Ltb -lt 11 ];do Ltb=$(($Ltb+1)) # echo ${TbStat[$Ltb]} echo "variable ---->""${f#*}" # if [ "${f#*${TbStat[$Ltb]}}" != "${TbStat[$Ltb]}" ] ; then if [ ("${f#*}" = "${TbStat[$Ltb]}") -o ("${f#*${TbStat[$Ltb]}}" = "${TbStat[$Ltb]}") ] ; then #echo "oui ------>" "${f#*${TbStat[$Ltb]}}" "=====" "${TbStat[$Ltb]}}" echo "oui ------>" "${f#*}" "=====" "${TbStat[$Ltb]}" else #echo "non ------<" "${f#*${TbStat[$Ltb]}}" "=====" "${TbStat[$Ltb]}}" echo "non ------<" "${f#*}" "=====" "${TbStat[$Ltb]}" fi echo $Ltb done sleep $p esac done IP=$(/sbin/ifconfig | grep "inet adr:192" | cut -d ":" -f2 |cut -d " " -f1) echo $IP exit 0