OK, I made this script to list the TCP open ports and their running service
netstat -aAn|grep LISTEN|while read socket b c d puerto resto;do echo "PUERTO: "`echo $puerto|cut -f2 -d"."` ------\> `rmsock $socket tcpcb|sed 's/^.* \([0-9][0-9]*\)/PID \1/'`;done
Similar I made this one for UDP (but does not works, it takes toooo long time and does not show the list)
netstat -aAn|grep udp|grep "*.[0-9]"|while read socket b c d puerto resto;do echo "PUERTO: "`echo $puerto|sed s'/\*\.//'` -----\> `rmsock $socket inpcb|sed 's/^.* \([0-9][0-9]*\)/PID \1/'`;done
I know with lsof -i :$port shows the service that is listening. This could be another way...
Can you help me to improve this script to list all TCP and UDP ports and their listening's service ?