Re: (newbie) storing outputs from all lines of procs into a string
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Re: (newbie) storing outputs from all lines of procs into a string

From: Ralf Fassel <ralfixx@gmx.de>
Date: Tue Dec 20 2005 - 12:25:50 CET

* just80n@gmail.com
| proc ex {COMMAND} {
| set OUTPUT ""
| rename puts _puts
| proc puts {args} { append OUTPUT $args "\n"; eval _puts $args }
| eval $COMMAND

Better catch that in case of errors, otherwise you lose the original
'puts' command.

  set err [catch $COMMAND msg]
  rename puts {}
  rename _puts puts
  if {$err} {error $msg}

  return $::OUTPUT

R'
Received on Fri Dec 23 19:02:27 2005