rafalry
rafalry

Reputation: 2670

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

Upvotes: 7

Views: 5287

Answers (1)

kjp
kjp

Reputation: 3116

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

Upvotes: 10

Related Questions