Avatar of LindaC
LindaC
Flag for Puerto Rico asked on

I need a script for unix Aix to see if the follwoing ports area available or not (a list)

Hi experts.

I need a script that will provide a list to see if the following ports area available or not:


Ensure that the ports you assign (within the given range) to the
following components are free and available:
¦ Admin Server HTTP SSL Port = 7101 - 7200
¦ Enterprise Manager Upload HTTP Port = 4889 - 4898
¦ Enterprise Manager Upload HTTP SSL Port = 1159, 4899 - 4908
¦ Enterprise Manager Central Console HTTP Port = 7788 - 7798
¦ Enterprise Manager Central Console HTTP SSL Port = 7799 -
7809
¦ Oracle Management Agent Port = 3872, 1830 - 1849
To verify if a port is free, run the following command:
¦ On Unix:
netstat -anp | grep <port no>
Unix OS

Avatar of undefined
Last Comment
LindaC

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
woolmilkporc

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
LindaC

ASKER
It ran ok, but I don't have a log to see.
woolmilkporc

Well,

why dont you redirect the output to a log, like

scriptname > /path/to/logfile

Sorry, I really didn't assume I had to tell you such things.
LindaC

ASKER
Oh! That's what stress does!
How can I ...

Thanks a lot as always!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
LindaC

ASKER
Thank you
woolmilkporc

Hi Linda,

thx for the points!

Please note these small changes in the script.
They will make the results more accurate,
and you can (but don't have to) put a hypen (-) between start and end port.

wmp

#!/bin/ksh
function checkport {
set $(echo "$@" | tr "-" " ")
PF=$1
PT=${2:-$PF}
while [[ $PF -le $PT ]] ; do
INU=$(netstat -an |grep -F ".${PF} ")
[[ -z $INU ]] && echo "Port $PF is free" || echo "$INU"
((PF+=1)); done
}

checkport 7101-7200
checkport 4889 4898
checkport 1159
checkport 4899-4908
checkport 7788 7798
checkport 7799-7809
checkport 3872
checkport 1830 1849
LindaC

ASKER
Thanks!
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.