Do you want to write an interactive script with some read commands or... ? What do you mean by input and output? For which tool/script is this input/output?
Please explain what you want to achieve, thanks.
You can it do the way you already did or check the server.xml of your Tomcat where the ports are defined in and grep it out of there. When having the port(s), you can just check additionally with
if it is up and running.
The way you have chosen, you do not know how many Tomcat installations/configurations are there, but just check which is up and try to get it's port.
It depends which way you want to go.
You should be able to grep the port tomcat is listening on from the output of lsof
Dear shamrock, i tried as you told And zaxxon, what you told is correct only. I can get it from server.xml file.
But my problem is : we have to use this script in a number of servers. And the server.xml file may be manually edited. There will be http & https connections also. The part <Connector port="portNum" will edit manually. And there is a chance to change the alignment also.
So upto my knowledge , there is only one way , that to GET the PORT number from PROCESS id.
Shamrock's idea is correct and good. The only difference is, that if you want an absolute list of ports of configured ports (not only those that are currently up and running), you will not get it by checking which processes are there, since it could be, that one of them is down for maintenance or similar.
For the problem of the format the server.xml could be in due to manual editing, I would try to run following via ssh from one box that has hopefully access to all others so you don't have to log in into each of them. For stuff like this I usually do something like the following (of course depending they are in a similar directory - else you have to think about how to find those server.xml in different locations):
On a box where 3 instances of Tomcat are running, I get something like:
Which are up and running you could get the other way with ps and lsof.
Hi,
I do not have root user credentials nor do I have the functional id of the process that uses port 80.
How can I find the pid of the process using the port number 80 ?
Operating System: Linux (6 Replies)
Hi,
Is this the most appropriate way of finding the listen port number given the pid is "16659" ?
lsof -Pan -i tcp -i udp | grep 16659 | grep -i "listen"If so, how can I extract "7001" and assign it to a variable say myport=7001 from the below output which happens to be actual port number?
... (1 Reply)
Hi,
I need to find the PID for a given port on the below system.
HP-UX mymachine B.11.31 U ia64 3223107173 unlimited-user license
How can I ? (4 Replies)
Hi
#Testing for file existence
if ; then
echo 'SCHOOL data is available for processing'
else
echo 'SCHOOL DATA IS NOT AVAILABLE FOR PROCESSING'
:
i wrote a script, where it begins by checking if file exists or not.
If it exists, it truncates the database... (2 Replies)
Hello guys,
How to shut down a port number in AIX.
May be first I need to find out what is the process ID of that process that listens to this particular port.. Is there any command to find a process ID from the port number other than "lsof".
thanks (1 Reply)
Hi,
I am working on HP-UX Release 11i.
I want to find the process id (PID) of the process running on a particular port.
lsof command fuser does not work on this system.
Please suggest some alternative.
Thanks (6 Replies)
1. If I use an software application(which connects to the database in the server) in my local pc, how many PID should be registered? Would there be PID for the session and another PID for socket connection?
2. I noticed (through netstat) that when I logged in using the my software application,... (1 Reply)