Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if port is open in ANT

Is it possible to check whether a port is open using ANT tasks?

I need to execute flexunit task, but before I start this task I need to check if another flexunit task is not running and blocking the desired port.

Thank you for any suggestions,

Rafal

like image 858
rafalry Avatar asked Jun 30 '11 12:06

rafalry


People also ask

How to check if port is open or not?

Check if port is open using online tools: On our main website, we have a tool that you can use just for that. you can set a target and a port number and it will tell you if this port is open or not. Why not give it a try. Go haad and test it. The advantage of n online port checker is that you are testing the port from outside of your local network.

What is the open Port Checker used for?

The open port checker is a tool you can use to check your external IP address and detect open ports on your connection. This tool is useful for finding out if your port forwarding is setup correctly or if your server applications are being blocked by a firewall. This tool may also be used as a port scanner to scan your network for ports that ...

How to check if port 25 is open on my router?

Type nc -vz (your router's IP address) (port). For example, if you wanted to see if port 25 is open on your router, and your router's IP address is 10.0.0.1, you would type nc -vz 10.0.0.1 25. 4

How to check whether a remote network port is open and listening?

Let’s check whether a remote network port is open and listening or not. Open PowerShell by going to Run –> powershell tns is short for Test-NetworkConnection command. google.com is the host name. You can also put an IP address instead of the host name. You can specify the port number using the -port switch at the end of tnc command.


1 Answers

Use the ant socket condition.

<target name="check-port" description="Check whether Tomcat is running">
    <echo message="Checking whether Tomcat is running"/>
    <condition property="tomcat.running">
      <socket server="${tomcat.host}" port="${tomcat.port}"/> 
    </condition>
</target>

http://ant.apache.org/manual/Tasks/conditions.html

like image 133
kjp Avatar answered Nov 09 '22 16:11

kjp