Posted to tcl by Bradipo at Fri Apr 19 19:57:39 GMT 2024view pretty
$ cat /tmp/random.tcl #!/bin/sh # \ exec tclsh "$0" ${1+"$@"} set fd [open /tmp/random.txt rb] fconfigure stdout -translation binary fcopy $fd stdout catch {close $fd} # now I start tcpserver and observe with tcpclient (below) $ tcpserver -v 127.0.0.1 12345 /tmp/random.tcl tcpserver: status: 0/40 tcpserver: status: 1/40 tcpserver: pid 66026 from 127.0.0.1 tcpserver: ok 66026 localhost:127.0.0.1:12345 localhost:127.0.0.1:jj3y4uadlcr7pgw4lu6r:2638 tcpserver: end 66026 status 0 tcpserver: status: 0/40 $ tcpclient -v 127.0.0.1 12345 /bin/sh -c 'cat <&6' > /tmp/random.fcopy tcpclient: connected to 127.0.0.1 port 12345 $ md5 /tmp/random.fcopy /tmp/random.txt MD5 (/tmp/random.fcopy) = 61e3b5fc3c2350eef8c4bd54c8a62b77 MD5 (/tmp/random.txt) = 61e3b5fc3c2350eef8c4bd54c8a62b77