Hello Friends,
First of all im sorry for spending extra space in DB of forum with this thread, i know there would be a solution if i kept searching,
I need to terminate the process which causes CLOSE_WAIT status of TCP connection via port 8103:
-bash-3.00$ netstat -na | grep 8103
127.0.0.1.8103 127.0.0.1.63876 49152 0 49152 0 CLOSE_WAIT
127.0.0.1.8103 127.0.0.1.39286 49152 0 49152 0 CLOSE_WAIT
127.0.0.1.8103 127.0.0.1.60796 49152 0 49152 0 CLOSE_WAIT
*.8103 *.* 0 0 49152 0 LISTEN
127.0.0.1.8103 127.0.0.1.62363 49152 0 49152 0 CLOSE_WAIT
I found this script FPMurphy posted on a thread here but i couldnt make it work for Solaris:
PORT=8103
PIDS=`ps -ef | sed 1d | awk '{print $2}'`
for pid in $PIDS
do
/usr/proc/bin/pfiles $pid 2>/dev/null | grep -q "port: $PORT"
if [[ $? -eq 0 ]] ; then
echo "Port: $PORT is being used by PID: \c"
ps -o pid -o args -p $PID | sed 1d
fi
done
Function of grep -q in Linux is not provided on solaris.. So i got this:
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .
So i tried below part with xargs even without being sure about how exact output of "/usr/proc/bin/pfiles $pid" part seems like, im sorry a bit stuck with time...
PORT=8103
PIDS=`ps -ef | sed 1d | awk '{print $2}'`
for pid in $PIDS
do
/usr/proc/bin/pfiles $pid 2>/dev/null | xargs grep "port: $PORT"
if [[ $? -eq 0 ]] ; then
echo "Port: $PORT is being used by PID: \c"
ps -o pid -o args -p $PID | sed 1d
fi
done
I had this meaningless output:
grep: can't open 23534:
grep: can't open -bash
grep: can't open Current
grep: can't open rlimit:
grep: can't open 256
grep: can't open file
grep: can't open descriptors
grep: can't open 0:
grep: can't open S_IFCHR
grep: can't open mode:0600
grep: can't open dev:292,0
grep: can't open ino:12582922
grep: can't open uid:100
Any suggestion welcome,
Thanks in advance,
Kind Regards