capture
Returns a command's output as a string
Format:
capture command
Arguments:
command
The CLI command (or commands) whose output is being captured. If you are specifying more than one command, you must enclose them within braces ({ }).
Description:
The capture command executes command, capturing all output that would normally go to the console into a string. After command completes, it returns the string. The capture command lets you obtain the printed output of any CLI command so that you can assign it to a variable or otherwise manipulate it. This command is analogous to the UNIX shell's back-tick feature; that is, `command`.
Examples:
set save_stat [ capture st ]
Saves the current process status into a Tcl variable.
set vbl [ capture {foreach i {1 2 3 4} {p int2_array($i )}} ]
Saves the printed output of four array elements into a Tcl variable. Here is some sample output:
int2_array(1) = -8 (0xfff8)
int2_array(2) = -6 (0xfffa)
int2_array(3) = -4 (0xfffc)
int2_array(4) = -2 (0xfffe)
Because capture records all of the information sent to it by the commands in the foreach, you do not have to use a dlist command.
exec cat << [ capture help commands ] > cli_help.txt
Writes the help text for all TotalView commands to the cli_help.txt file.