Get application pid listening on a network port in Solaris (aka netstat -npl in Solaris?)
By Lubos Kosco on Jul 24, 2006
Some time ago, I was in need of this functionality.
This little silly script, however very uneffective will check which apps listents on the given port number.
Maybe I should think about writing something more effective ... or just file a Request For Enhancement against netstat on Solaris?
# Get the process which listens on port
# $1 is the port we are looking for
if [ $# -lt 1 ]
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
echo "Greping for your port, please be patient (CTRL+C breaks) ... "
for i in `ls /proc`
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
echo Is owned by pid $i