how to detect port open status?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to detect port open status?
# 1  
Old 05-07-2010
how to detect port open status?

I write a script which will stop an application, then restart it.

Sometimes it is succesful, sometimes not.

The problem is, when stop the application, some ports are still listenning (or not released). When start the application, it reports that ports are used, and can't continues.

I use
"Sleep 60"

to delay the start job, but seems somtime I need wait for more than 5 minutes to release the ports.

Are there any way to detect the ports, and wait until the ports are all released?

My env is Solaris 10.
# 2  
Old 05-07-2010
Why don't u check with netstat

netstat -an | grep $port
if [ $? -eq 0 ]
    echo "$port is free"
    echo "$port is listening"

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

Tcp ip port open but no such process (merged: Release A Port)

i want to kill a tcp connection by killing its pid with netstat -an i got the tcp ip connection on port 5914 but when i type ps -a or ps-e there is not such process running on port 5914 is it possible that because i do not log on with proper user account i can not see that process running? (30 Replies)
Discussion started by: alinamadchian
30 Replies

2. AIX

How to detect the network cable status with c programming on AIX

Hello, Is there any API or any other approach to detect whether the network cable is connected to the network adapter, say, en0, en1 or en2? The OS is AIX6.1. Thank you. (4 Replies)
Discussion started by: zephyrbj
4 Replies

3. Cybersecurity

Detect port scanning without psad - write own IDS

Hi gurus, 1st: Is possible to detect port scanning just by using utilities included in linux (netstat, iptables...), Yes there is utility called psad but I would write some scripts for my own and learn something new :) 2nd: Could you point me to good tutorial for writing own Intrusion... (1 Reply)
Discussion started by: wakatana
1 Replies

4. Programming

Getting TCP Port status through C API

Does anyone know if there is a C API call to get the status of a TCP port? As opposed to running netstat and parsing the results. At the moment I have to attempt to bind() and pick up on the address in use error which isn't very elegant Thanks ---------- Post updated at 10:42 AM ----------... (0 Replies)
Discussion started by: janra
0 Replies

5. Shell Programming and Scripting

set a variable and detect error status...

Hi there, I'm driven crazy by a new problem. It seems very complex to me and I see no way to come around. In my script, I receive the path to a tgz file and I want to output the md5 sum of the file inside the tgz. I want a way to detect if tar fails. I'm using the following command tar... (7 Replies)
Discussion started by: chebarbudo
7 Replies

6. Solaris

Port status/Running daemon

Hi, I need to run an application (Hudson) listening to port 8080 on a remote Solaris server. I have managed to start that application and tried to access it with my browser from my local PC, but unsuccessfully. I need to find out what is blocking the access to that port (or any other). A... (9 Replies)
Discussion started by: JVerstry
9 Replies

7. IP Networking

Unknown open port: "6881/tcp open bittorrent-tracker" found with nmap

Hi. I ran nmap on my server, and I get the following: Starting Nmap 4.76 ( ) at 2009-03-19 16:33 EDT Interesting ports on -------- (-----): Not shown: 997 closed ports PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 6881/tcp open bittorrent-tracker The... (0 Replies)
Discussion started by: Rledley
0 Replies

8. AIX

how to check status of various services and port?

How can i check which service is activated on my AIX Box? how one can check particular port is open or not (like ftp/telnet port)? I dont have admin rights (1 Reply)
Discussion started by: ashish4422
1 Replies

9. UNIX for Advanced & Expert Users

Unix port status

disregard solved (0 Replies)
Discussion started by: calamine
0 Replies

10. UNIX for Dummies Questions & Answers

Couldn't open status file /var/samba/STATUS.LCK

I believe i have most of samba configured right but i get this error each time time try to run it. I was given suggestion that i touch the file, i did, but i still cannot rid myself of this error. Any suggestions (2 Replies)
Discussion started by: macdonto
2 Replies
Login or Register to Ask a Question

Featured Tech Videos