If I run a normal interactive python session, input/output looks like this:>>> 1 + 1;2Now I'm trying to run it through socat, so I start a serversocat UNIX-LISTEN:$HOME/socket,fork EXEC:python,pty,stderrAnd connect to it from another terminal:socat - UNIX-CONNECT:$HOME/socketWhich works almost fine except the input is echoed again too:>>> 1 + 1;1 + 1;2How can I turn this off? echo=0 does not do what I want: this hides the input while I'm typing as well which is not very helpful. I want it to work just like a normal interactive session.(using python and a local domain socket is just an example; the same occurs with other programs (e.g. cat, lua etc.) and other socket types, e.g. a TCP socket.
socat disable double echo
socat
write either this on client side . notice the raw .socat unix-connect:socket -,raw,echo=0or this on server side . notice the echo=0socat unix-listen:socket exec:python,pty,echo=0but not both . alternatively raw on client stdio with echo=0 on the server pty is fine , but echo=0 must not be applied twice .lets look at the two 1+1's . they are echos but with different meanings . the first echo is from line buffering of the client terminal , and the second is from the terminal on the server side created by socat .>>> 1 + 1;1 + 1;2use of echo=0 alone on client stdio , socat informs its controlling terminal ( i.e. xterm or anything like ) to disable the echoing ( on-screen-display ) of stdio buffer , thus the first 1+1 disappears , and the second will show in the very place once return key is pressed . echo=0 on server pty prevents socat from echoing ( ping-pong ) the input it receives back to the client , thus the second 1+1 disappears . with raw on the client , buffering of stdio is disabled so every key don't wait till a return to be sent to the server , and server echos the key back immediatly . use raw on client stdio along with echo=0 on client stdio when a key is pressed it is first sent to the server then the server sends it back and is displayed on the client . use raw on client stdio along with echo=0 on server pty when a key is pressed it is displayed simultanously as it is sent to the server , but is never sent back .for commandline editing ,  sometimes it is sufficient to buffer a line on the client side and not send a whole line until we finish editing this line . however if powerful smart completion is desired , server side involvement is necessary .