I have a netcat installed on my local machine and a service running on port 25565. Using the command:
nc 127.0.0.1 25565 < /dev/null; echo $?
You could try something like
while true; do nc 127.0.0.1 25565 < /dev/null if [ $? -eq 0 ]; then break fi sleep 1 done echo "The command output changed!"