This question already has an answer here:
When I am writing a bash script like the following:
#!/bin/bash nc localhost [pseudoport] echo "test"
it connects to the server but does not send the text "test".
It works with
#!/bin/bash echo "test" | nc localhost [pseudoport]
The problem here is that the connection exits after something has been received.
How can I send multiple messages, in my case a fixed preamble followed by a variable data?