1

I'm trying to set up a simple server that returns always the same response.

Based on this question I've tried to use

ncat -l 2000 --keep-open --exec "/bin/echo 234"

but on the client it shows only once.

Ncat: Broken pipe.

If I use the UDP option (-u), it works as intended. So I'm guessing it's EOF's fault.

Is there a way to make it work as a reponse to the client's messages in TCP?

AusiasMart
  • 53
  • 1
  • 5

1 Answers1

1

For something as simple you could:

ncat -l 2000 --keep-open --exec "xargs -I{} echo 234"

I find also the following works:

ncat -l 2000 --keep-open --sh-exec "while read line; do echo 234; done"

or like:

ncat -l 2000 --keep-open --sh-exec "echo 234; cat >/dev/null"
KamilCuk
  • 120,984
  • 8
  • 59
  • 111