In search for questions.

Content by Tyches.
Licensed under CC by.

Theme by nostrich, altered by Tyches.

29th March 2010

Text

Lovely command to obtain the processes (or rather, PID) using a socket port (here 23) on AIX:

$ netstat -Aan  | egrep '\.23 ' | awk '{print $1}' | \
    sed -e 's/^\(.*\)$/sockinfo \1 tcpcb/' | kdb | egrep '^pvproc' | awk '{print $4}'  | sort | uniq | \
    sed 's/^\(.*\)$/hcal \1/' | kdb | grep Value | awk '{print $6}'

Useful when you don’t have lsof at hand.