title: bash command to wait until TCP port is opened
body: <p>I want my micro services to open in a new command line and run it from there one after the other. below is my bash script</p>
  
  <pre class="lang-bash prettyprint-override"><code>################ first SERVER #####################
  gnome-terminal -x sh -c 'java -jar server/target/first-server.jar; exec bash'
  
  ################ second SERVER #####################
  export service_port=8771
  export host_name=firstdomain
  gnome-terminal -x sh -c 'java -Dservice.port="${service_port}" -Dhost.name="${host_name}" -jar eureka/target/second-server.jar; exec bash'
  </code></pre>
  
  <p>The problem is it that i want to start my <strong>"second-server.jar"</strong> after successfully started the <strong>"first-server.jar"</strong>. I can detect that by checking if the service is listening to network port. Is there any way to archive this? <strong>sleep</strong> bash command is not a option for me.</p>