Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Getting which pid uses a specific port on SunOS 5.8

Posted on 2004-09-30
4
Medium Priority
?
1,317 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
2 Comments
 
LVL 38

Accepted Solution

by:
yuzh earned 152 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 148 total points
ID: 12388924

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

Mark

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.
Suggested Courses

877 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