How to know which application is using which port on Mac and Solaris

I am using often so...

Mac:

lsof -i -P | grep -i "listen"

OpenSolaris:

Here it is a little more complex.
I got a little script from the net that does that: give it the port you want to scan and it will give you the app using it.

opensolaris [~/bin] $ get_pid_from_port.sh
Please provide a port number parameter for this script
e.g. %content 1521

#!/bin/bash
# is the port we are looking for
if [ $# -lt 1 ]
then
echo "Please provide a port number parameter for this script"
echo "e.g. %content 1521"
exit
fi
echo "Greping for your port, please be patient (CTRL+C breaks) ~E "
for i in `ls /proc`
do
pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
then
echo Is owned by pid $i
echo -----
fi
done

 

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed
About

Members of the EMEA Globalization Center are blogging about the products that comprise the Java Enterprise System stack.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today