#!/usr/bin/tclsh set handle [socket 127.0.0.1 8888] fconfigure $handle -blocking 0 -buffering none puts $handle command=edit_config_new&which_samples=E*TRADE+live # Note: the diconnect command is no longer handled in series # with any other commands. disconnect is likely to be processed # before any other commands you send, unless there is a pause. after 500 puts $handle command=disconnect while {![eof $handle]} { append result [read $handle] after 100 } regexp {^([^\n]*)\n(.*)$} $result {} header body regsub -all {><} $body ">\n<" formatted set out [open /tmp/ETrade.Config.1.xml {WRONLY TRUNC CREAT}] puts $out $formatted