Solved

Getting which pid uses a specific port on SunOS 5.8

Posted on 2004-09-30
4
1,279 Views
Last Modified: 2012-05-05
How would I be able to get pid that uses a specific port on SunOS 5.8?

More important is if you could tell me what did you/should I reference to answer this next time.

Thank you.
0
Comment
Question by:InGearX
4 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 38 total points
ID: 12196145
Here's a script for you to do the job:

#!/usr/bin/ksh
echo -n "which port?> "
read port

for pid in `ps -ef -o pid | tail +2`
do
  foundport=`pfiles $pid 2>&1 | grep "sockname:" | grep "port: $port$" |
awk
'{print $NF}'`
  if [ "$foundport" != "" ]; then
    foundproc=`pfiles $pid 2>&1 | grep "^$pid:"`
    echo "$foundproc, $foundport"
  fi
done

exit

0
 
LVL 1

Assisted Solution

by:mdhmi
mdhmi earned 37 total points
ID: 12388924

Use lsof.  If you don't already have lsof you can download it from sunfreeware.com.

Mark

0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question