$ nc -Ulk /tmp/socket
# -U - open unix socket
# -l - open for listening
# -k - keep open for multiple connections
Add echo function to Python code
import socket
conn = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
conn.connect('/tmp/socket')
# ^ this will fail if nobody is listening on Unix socket
echo
function to Python codedef echo(msg): conn.sendall(msg + '\n') echo('--- start ---') echo(sys.executable)