Posted to tcl by Bradipo at Fri Apr 19 20:43:26 GMT 2024view pretty

#!/bin/sh
# \
exec tclsh "$0" ${1+"$@"}

set fd [open /tmp/random.txt rb]
puts stderr $fd
fconfigure stdout -translation crlf
fcopy $fd stdout
catch {close $fd}

# tcpserver output
tcpserver: status: 1/40
tcpserver: pid 1645 from 127.0.0.1
tcpserver: ok 1645 localhost:127.0.0.1:12345 localhost:127.0.0.1:dnawew9xhief6mgaig5y:40489
file3
error writing "sock1": invalid argument
    while executing
"fcopy $fd stdout"
    (file "/tmp/random.tcl" line 8)
tcpserver: end 1645 status 256
tcpserver: status: 0/40

# tcpclient
$ tcpclient -v 127.0.0.1 12345 /bin/sh -c 'cat <&6' > /tmp/random.fcopy
tcpclient: connected to 127.0.0.1 port 12345