Skip to content

Instantly share code, notes, and snippets.

@jsidhu
Created April 11, 2017 05:16
Show Gist options
  • Save jsidhu/f17d0d7db46d0625bfaab935e294143c to your computer and use it in GitHub Desktop.
Save jsidhu/f17d0d7db46d0625bfaab935e294143c to your computer and use it in GitHub Desktop.
#!/bin/bash
HOST=$1
PORT=$2
timeout 1 bash -c "cat < /dev/null > /dev/tcp/${HOST}/${PORT}"
RESULT=$?
if [ "${RESULT}" -ne 0 ]; then
echo "Failed: ${RESULT}"
else
echo "Connected: ${RESULT}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment