Hi,
I am triying to run this script in order to find the pid for each open port and when I run it in one server it give me an error and for another server is not showing the same error. Below I pasted the script and the result.
script
#!/usr/bin/ksh
print "Port PID Process"
netstat -Aan | grep LISTEN | awk '{print $1 " " $5}'| tr -d "*." | while read pcb port; do
out=`rmsock $pcb tcpcb`
if echo "$out" | grep "Kernel Extension" > /dev/null; then
printf "%-15s Kernel Extension\n" "$port"
else
pid=`echo "$out" | sed -n 's/.*pro[c]*ess \([0-9][0-9]*\) .*/\1/p'`
if [ -n "$pid" ]; then
proc=`ps -p $pid | tail -n 1 | awk '{print $4}'`
printf "%-15s %-16s $proc\n" "$port" $pid
else
echo "Error, Line not recognized \"$out\" for Port $port"
fi
fi
done
output for one server
$ ports.sh
Port PID Process
rmsock : Unable to read kernel address f1000600011c8b98, errno = 13
Error, Line not recognized "" for Port 21
rmsock : Unable to read kernel address f100060001236b98, errno = 13
Error, Line not recognized "" for Port 22
rmsock : Unable to read kernel address f10006000121e398, errno = 13
Error, Line not recognized "" for Port 23
rmsock : Unable to read kernel address f10006000121eb98, errno = 13
Error, Line not recognized "" for Port 111
rmsock : Unable to read kernel address f10006000123a398, errno = 13
Error, Line not recognized "" for Port 657
rmsock : Unable to read kernel address f10006000123b398, errno = 13
Error, Line not recognized "" for Port 1334
rmsock : Unable to read kernel address f100060000427398, errno = 13
Error, Line not recognized "" for Port 1950
rmsock : Unable to read kernel address f100060001212398, errno = 13
Error, Line not recognized "" for Port 32768
rmsock : Unable to read kernel address f100060001212b98, errno = 13
Error, Line not recognized "" for Port 32769
rmsock : Unable to read kernel address f100060000436b98, errno = 13
Error, Line not recognized "" for Port 1013355811953
output for other server
$ ports.sh
Port PID Process
*.21 4391118 inetd
*.22 5767352 sshd
*.22 5767352 sshd
*.23 4391118 inetd
Error, Line not recognized "Wait for exiting processes to be cleaned up before removing the socket" for Port *.111
*.427 1638586 slp_srvreg
*.657 7733484 rmcd
*.1334 5505192 writesrv
*.1950 5898446 java
*.5988 10420422 cimserver
*.5989 10420422 cimserver
*.6181 4391118 inetd
Error, Line not recognized "Wait for exiting processes to be cleaned up before removing the socket" for Port *.32770
*.9495 8585228 lcfd
*.16191 5308580 clcomd
I think this is relate with permitions.
Thanks and regards