Avatar of LindaC
LindaCFlag 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
ASKER CERTIFIED SOLUTION
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

It ran ok, but I don't have a log to see.
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

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.
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

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

Thanks a lot as always!
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

Thank you
Avatar of woolmilkporc
woolmilkporc
Flag of Germany image

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
Avatar of LindaC
LindaC
Flag of Puerto Rico image

ASKER

Thanks!
Unix OS
Unix OS

Unix is a multitasking, multi-user computer operating system originally developed in 1969 at Bell Labs. Today, it is a modern OS with many commercial flavors and licensees, including FreeBSD, Hewlett-Packard’s UX, IBM AIX and Apple Mac OS-X. Apart from its command-line interface, most UNIX variations support the standardized X Window System for GUIs, with the exception of the Mac OS, which uses a proprietary system.

33K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo