Using Socat on my server I have the current command:
socat -u tcp-l:7767,fork system:/app/getmsg.sh
All getmsgh.sh does is:
read MESSAGE
echo $MESSAGE
I'm trying to figure out a way for the client to send a message and receive the output of getmsg.sh
Trying on the client:
echo "hello" | socat -t 30 tcp:localhost:7767 -
Does not seem to work. It shows up on the server but not on the client. It seems that if you try to pass a message with the client socat wants to exit immediately
The problem is the -u
option on the server side. The meaning of the -u
option from the socat
man page:
Uses unidirectional mode. The first address is only used for reading, and the second address is only used for writing
Hence, the tcp-l:
side is only read from and the system:
side is only written to, instead of a bi-directonal connection (which is the default). Removing the -u
option makes the example in the question work.