Perhaps the gets command is what you want.
set data [gets stdin]
# or
set numchars [gets stdin data]
The scan command can be used to parse input, similar to how scanf works with C. It uses the format: scan string format? varName varName ...?
Thus, for parsing input data, such as “5 cats,” for individual variables:
set data [gets stdin]
scan $data "%d %s" myint mystring
Edit: Added more information from Colin's comment.
source
share