HI
I am trying to check the status of port using command
/code:
netstat -an | grep port
/Output:
.2009 *. 0 0 65535 0 LISTEN
what i am trying to do is
i want to grep only status Wether the port is established/listen if so show ok else show error
and for same i am using below code:
/code:
netstat -an | grep *.2009 |awk '{ if ($7!="LISTEN" || $7!="ESTABLISHED")print "OK" ; else print $7;}'
/output:
OK
In this code i am trying to print ok if port is in "LISTEN and ESTABLISHED" mode else print $7(port status)
but when i run this code it always show OK either port is established or not.
Kindly correct it or suggest me the right code.