# usage : randString <min> <max>
proc randString { {min 1} {max 8} } {
set chars "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
set size [expr {int(rand()*($max-$min+1)+$min)}]
set range [string length $chars]
set txt ""
for {set i 0} {$i < $size} {incr i} {
set pos [expr {int(rand()*$range)}]
append txt [string index $chars $pos]
}
return $txt
}
If min is not defined, it's between 1 and 8 chars.
If min is defined, between <min> and 8 chars long (min must be lower than 8, I didn't check the values)
If min and max are defined, it's between <min> and <max> chars long (idem)