0

I have a sh that is meant to run in linux.

But im using windows, and I must be able to run it in windows

Theres a piece of code that does the following

while ! nc -z localhost 3300; do
    echo "Waiting for MariaDb"
    sleep 0.1
done

But im unable to replicate it in windows since nc doesnt work.

What is the alternative to the exact command?

mouchin777
  • 117
  • 1
  • 6

1 Answers1

0

I believe you can do it with basic telnet but powershell probably has some better way to do it. This is how it could be done in bash:

$ exit=0 ; while (( exit != 1)) ; do { echo "open 127.0.0.1 22" ; sleep 2; } | \
  telnet 2>/dev/null | grep -q '^Connected to 127.0.0.1.' && exit=1 || echo 'Waiting for SSH...' ; done
Waiting for SSH...
Waiting for SSH...
Waiting for SSH...
Waiting for SSH...
Waiting for SSH...
Jiri B
  • 547
  • 2
  • 15
  • If you haven't 'enabled' telnet, Windows nowadays doesn't make it available unless you go to `Control Panel > Programs and Features > Turn Windows features on or off` and then tick the box for 'Telnet Client'. – JellicleCat May 12 '22 at 23:32