Posted to tcl by aspect at Wed Nov 09 13:18:33 GMT 2011view raw

  1. #!/usr/bin/tclsh
  2. #
  3. # the files I am reading are shell scripts with tgz appended to them,
  4. # intended to be read by "tail -n +100 | tar xzv". Why do I need to
  5. # [seek $f [tell $f]] after [chan configure]?
  6. #
  7. foreach fn [glob *.exe] {
  8. set basename [lindex [split $fn _.] 1]
  9. file mkdir $basename
  10.  
  11. set f [open $fn]
  12. while {[set l [gets $f]] != "exit"} {}
  13.  
  14. chan configure $f -encoding binary -translation binary
  15.  
  16. # needing to do this is a bit odd
  17. seek $f [tell $f]
  18.  
  19. exec tar -C $basename -xzv <@ $f
  20.  
  21. close $f
  22. }
  23.