Blog dedicated to Oracle Applications (E-Business Suite) Technology; covers Apps Architecture, Administration and third party bolt-ons to Apps

Showing posts with label script. Show all posts
Showing posts with label script. Show all posts

Monday, May 18, 2009

Script to get the process which listens on a port number

In Solaris 10, lsof utility doesn't work. Here's a script given by Oracle in Metalink Note 839919.1 to help us:

#!/bin/bash

# Get the process which listens on port

# $1 is the port we are looking for

if [ $# -lt 1 ]
then
echo "Please provide a port number parameter for this script"
echo "e.g. $0 22"
exit
fi

echo "Greping for your port, please be patient (CTRL+C breaks) ... "

for i in `ls /proc`
do
[ -d /proc/$i ] && pfiles $i | grep AF_INET | grep $1
if [ $? -eq 0 ]
then
echo Is owned by pid $i
fi
done