Posted to tcl by Bradipo at Fri Apr 19 19:57:39 GMT 2024view raw

  1. $ cat /tmp/random.tcl
  2. #!/bin/sh
  3. # \
  4. exec tclsh "$0" ${1+"$@"}
  5.  
  6. set fd [open /tmp/random.txt rb]
  7. fconfigure stdout -translation binary
  8. fcopy $fd stdout
  9. catch {close $fd}
  10.  
  11. # now I start tcpserver and observe with tcpclient (below)
  12.  
  13. $ tcpserver -v 127.0.0.1 12345 /tmp/random.tcl
  14. tcpserver: status: 0/40
  15. tcpserver: status: 1/40
  16. tcpserver: pid 66026 from 127.0.0.1
  17. tcpserver: ok 66026 localhost:127.0.0.1:12345 localhost:127.0.0.1:jj3y4uadlcr7pgw4lu6r:2638
  18. tcpserver: end 66026 status 0
  19. tcpserver: status: 0/40
  20.  
  21. $ tcpclient -v 127.0.0.1 12345 /bin/sh -c 'cat <&6' > /tmp/random.fcopy
  22. tcpclient: connected to 127.0.0.1 port 12345
  23.  
  24. $ md5 /tmp/random.fcopy /tmp/random.txt
  25. MD5 (/tmp/random.fcopy) = 61e3b5fc3c2350eef8c4bd54c8a62b77
  26. MD5 (/tmp/random.txt) = 61e3b5fc3c2350eef8c4bd54c8a62b77
  27.