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
Code:
#!/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
Code:
$ 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
Code:
$ 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
Last edited by vbe; 09-12-2013 at 12:59 PM..
Reason: code tags...
Hello everyone,
while setting up the Horde framework on OpenBSD 3.0, I discovered the following error:
configure: error: Cannot find rfc822.h. Please check your IMAP installation.
*** Error code 1
Stop in /usr/ports/www/php4 (line 1703 of /usr/ports/infrastructure/mk/bsd.port.mk).
***... (1 Reply)
Hi Guys,
could you help me with this.
I need a script where if we enter the hostname and range of port numbers, the script must be able to give me the ports that were unassigned to any of the services installed.
Thanks,
Charan (5 Replies)
Dear all,
good day.
i'm asking about how to disable <control>-c or <control>-z in the beginning of a shell script then enable it again before the script exit
Best Regards
---------- Post updated at 04:41 AM ---------- Previous update was at 04:18 AM ----------
Dear All
i found the... (3 Replies)
Hi,
I'm in need of a script that can monitor a list of 12 ports.. If one of the ports isn't in listening mode then email me..
The list of ports are 26401 - 26412.. (6 Replies)
Hello
I am trying to install fftw3.3.3 on an HPC system. The system has openmpi installed ( though we can choose between a variety of mpi distributions). However, while ./configure step of fftw, there is an error. The relevant section of the output is:
checking whether to build shared... (3 Replies)
Bash on Oracle Linux 6.3
I have a shell script whose output I want to redict to a log file. So, I can simply redirect the output as shown below.
# cat myscript.sh
#### I actually want some logging mechanism here which will redirect the output to a log file
echo 'hello world'
#... (3 Replies)
Hello there .
I have a unix box 5.0.06 , this is the error (Socket: All ports in use ).
Can anyone tellme how to resolve this problem.:(
Thanks a lot . (4 Replies)
Hi
I am exactly according to this link
CentOS 6 - Apache httpd - Enable Userdir : Server World
I Enabled userDirectory
Server version: Apache/2.2.15
CentOS release 6.8 (Final)
But Iget this Error
Forbidden
You don't have permission to access /~mn/index.html on this server
Goal... (2 Replies)
I have a bash shell script, within it i am using the below two commands . its failing right on scl enable command itself.
if i run it by itself without a shell, it works fine.
by default it is using pythin version 2.6 something. i want to use 3.4 version for that reason with in the shell... (3 Replies)