V
V
Vadim2021-09-16 18:40:08
linux
Vadim, 2021-09-16 18:40:08

How do you understand the work of the following command?

there is a command:

#!/bin/bash
if [ "$(echo PING | nc localhost 3010)" = "PONG" ]; then
  echo "ping successful"
else
  echo "ping failed"
  exit 1
fi


why does it return PONG (we have a tcp server running on 3010)? Is this the response to start establishing a tcp connection?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2021-09-16
@Viji

It all depends on the software that hangs on port 3010 - if in response to the PING line it in some cases answers PONG.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question