Script for enable ports error=13


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script for enable ports error=13
# 1  
Old 09-12-2013
Wrench Script for enable ports error=13

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
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...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to use scl enable python command call with in bash shell script?

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)
Discussion started by: cplusplus1
3 Replies

2. Red Hat

Runtime Error Enable user directory apache

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)
Discussion started by: mnnn
2 Replies

3. SCO

SCO 506 error Socket: All ports in use

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)
Discussion started by: YDO
4 Replies

4. Shell Programming and Scripting

Enable logging from within the shell script

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)
Discussion started by: John K
3 Replies

5. High Performance Computing

FFTW - ./configure --enable-mpi error.

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)
Discussion started by: abhi34101
3 Replies

6. Shell Programming and Scripting

Script to Monitor List of Ports

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)
Discussion started by: eclipseagent
6 Replies

7. Shell Programming and Scripting

how to disable and enable <control>-c or -z in a shell script

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)
Discussion started by: islam.said
3 Replies

8. UNIX for Advanced & Expert Users

script for unassigned ports

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)
Discussion started by: charan314
5 Replies

9. Shell Programming and Scripting

Csh script to enable a pop-up

Hi All, Can a csh script create a window-pop in textedit format if certain condition is true? Can anyone show a simple example ? (0 Replies)
Discussion started by: Raynon
0 Replies

10. UNIX for Dummies Questions & Answers

Error while setting up the Horde framework using OpenBSD ports

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)
Discussion started by: Lexx
1 Replies
Login or Register to Ask a Question