take 5333 port for example.
incore1:/u/ainet/hui-# cat tex.sh.sh
#!/usr/bin/ksh
ps -ef | grep -v grep | while read X PID X
do
#echo $PID
if pfiles $PID | grep 5333 > /dev/null 2>&1
then
echo $PID
else
:
fi
done
----------------------------------------------------------------------------------------------------------------------------------
Following lines are used to search out all TCP connection used by a process (for example, TestConnection)
----------------------------------------------------------------------------------------------------------------------------------
incore1:/u/ainet/hui-# cat tex.sh
#!/usr/bin/ksh
rm -f tex.log
ps -ef | grep -w TestConnection | grep -v grep | read X PID X
echo $PID
integer x=1
while(true)
do
echo -n "$x " | tee -a tex.log
ps -ef | grep -w TestConnection | grep -v grep | while read X PID X
do
pfiles $PID | grep AF | grep sockname | grep -v "0/.0/.0/.0" | while read X X X X PORT
do
netstat -an |grep $PORT | tee -a tex.log
done
sleep 1
x=$x+1
done
done