Yup.. I know what you mean.. however, this application doesn't allow for any type of connections through the port, since it's an internal license adapter. It just refuses connection when trying to telnet. The application cannot be modified, but I was told that 100% reliability that LISTEN means it's working (it's what I'm told from the application, so it's all I can agree to).
Here's what I've come up with:
NETSTAT=`netstat -ant | grep LISTEN | awk '{ print $4 }'`
CCTEST="my_email@email.com
another_email@email.com"
for PORT in `seq 26401 26412`; do
echo "$NETSTAT" | grep $PORT &> /dev/null
if [ $? -ne 0 ]; then
echo "Port $PORT is down on `hostname`i X.X" | mail -s "Port $PORT is down on `hostname`" $CCTEST
else
echo "Port $PORT is =)"
fi
done