The other day I had a request to find out what process was using a specific port on a Solaris 10 server. I came up with this little gem to do the work and provide the PID of the process using the port.
get_port.sh
#!/bin/bash
if [ $# -lt 1 ]
then
echo "Usage: ./get_port.sh port#"
exit
fi echo "Searching for PID using port... " for i in `ls /proc`
do
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
then echo The port is in use by PID: $i
fi
done