Finding Process ID (PID) using port number in solaris is not easy as Linux. If you are working on new services setup and would like to allocate some port, you got to check if that port is used by some other service. You can find out which process is using particular port in solaris by below tiny shell scripts.
Following scripts will prompt you to enter port number and it will use pfiles command internally to give you the pid.
======================================
#!/bin/ksh
line='---------------------------------------------'
pids=$(/usr/bin/ps -ef -o pid=)
if [ $# -eq 0 ]; then
read ans?"Enter Port Number To Know The pid: "
else
ans=$1
fi
for f in $pids
do
/usr/proc/bin/pfiles $f 2>/dev/null | /usr/xpg4/bin/grep -q "port: $ans"
if [ $? -eq 0 ]; then
echo $line
echo "Port: $ans is used by PID:\c"
pargs -l $f
fi
done
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment