Use `ss` instead of the deprecated `netstat`.

This commit is contained in:
Jeremy Gardais 2015-02-02 09:44:39 +01:00
parent f0d3126c30
commit 566450407e
1 changed files with 2 additions and 2 deletions

View File

@ -54,9 +54,9 @@ service_info() {
for PORT in ${PORT_LIST}; do for PORT in ${PORT_LIST}; do
MSG="${MSG}${MAGENTA}+ " MSG="${MSG}${MAGENTA}+ "
# If a port listen # If a port listen
if (netstat -lnt|grep -m1 ${PORT} > /dev/null); then if (ss -lutn|grep -m1 ":${PORT}" > /dev/null); then
# Example: "tcp/127.0.0.1:25" # Example: "tcp/127.0.0.1:25"
MSG="${MSG}${GREEN}$(netstat -lnt|grep -m1 ${PORT}|awk '{print $1"/"$4}')${RESET} " MSG="${MSG}${GREEN}$(ss -lutn|grep -m1 ":${PORT}"|awk '{print $1"/"$5}')${RESET} "
else else
# Example: "22: NOT LISTENING" # Example: "22: NOT LISTENING"
MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} " MSG="${MSG}${REDB}${PORT}: NOT LISTENING${RESET} "