Skip to content

Instantly share code, notes, and snippets.

@bodsch
Created August 10, 2018 15:59
Show Gist options
  • Save bodsch/af934cb488febc6c5cc2f9f276d18f05 to your computer and use it in GitHub Desktop.
Save bodsch/af934cb488febc6c5cc2f9f276d18f05 to your computer and use it in GitHub Desktop.
replacement for netcat
# now wait for ssh port
RETRY=20
until [[ ${RETRY} -le 0 ]]
do
timeout 1 bash -c "cat < /dev/null > /dev/tcp/${VM_NAME}.${VM_DOMAIN}/22" 2> /dev/null
if [ $? -eq 0 ]
then
break
else
sleep 20s
RETRY=$(expr ${RETRY} - 1)
fi
done
if [[ ${RETRY} -le 0 ]]
then
printf "${red} could not connect to ssh port for '${VM_NAME}' ${endColor}\n"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment