#!/bin/bash #this script is used to get tcp and udp connetion status pub=$1 net(){ netstat -ant | grep -c $1 } case $pub in ESTABLISHED) net $pub ;; CLOSED) net $pub ;; CLOSING) net $pub ;; CLOSE_WAIT) net $pub ;; TIME_WAIT) net $pub ;; LAST_ACK) net $pub ;; LISTEN) net $pub ;; SYN_RECV) net $pub ;; SYN_SENT) net $pub ;; FIN_WAIT1) net $pub ;; FIN_WAIT2) net $pub ;; *) echo -e "\e[033mUsage: sh $0 [closed|closing|closewait|synrecv|synsent|finwait1|finwait2|listen|established|lastack|timewait]\e[0m" ;; esac