1

I have set up a server with the usual nc - lk <port> command.

My client sends tcp data to the server socket in the form of xxx,yyy which are numbers.

I want every time the client connects that the values of xxx and yyy would be stored in variables in order to use them later.

From what I understood I must work with pipes, but I am not sure how to do this.

1 Answer 1

2

You have two options:

  1. Pipe the output to a file for later reading
  2. Read each line and do something with it in realtime:

For example:

nc -lk 8889 | while IFS=, read -a p
do echo ${p[1]} ${p[0]}
done
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.