Skip to main content
1 of 3
Alex Stragies
  • 6.2k
  • 2
  • 35
  • 58

Instead of tcp:127.0.0.1:12345 you could try spawning a shell_fragment/script, that more-or-less:

Check, if 127.0.0.1 12345 responds
  if yes, connect there and pass over the fds
  if no, echo "Service@12345 is down"
    Optional: don't exit, but enter a while loop
      Try reaching port 12345, then connect eventually

Something starting from here might help on your quest:

{ nc -z 127.0.0.1 12345 </dev/null 2>/dev/null \
  && exec nc 127.0.0.1 12345 } \
|| echo "Service @ 12345 not responding, try again later"

I can help, if you need help adapting this, just update your Q with info where you got stuck

Alex Stragies
  • 6.2k
  • 2
  • 35
  • 58