
proc recurse_again {dir level {maxlen 300}} {
    # just generate a random name for a file
    set fname [string range [expr rand()] 0 5]
    # make the very long path
    set fpath [file join $dir $fname]
    # create the file
    close [open $fpath w]
    puts stdout "file '$fname' at level $level, with length\
      [string length $fpath] exists: [file exists $fpath]"
    update
    if {[string length $fpath] > $maxlen} {
	puts stdout "Length exceeded $maxlen"
	return
    }
    incr level
    set dirname [file join $dir "dir${fname}"]
    file mkdir $dirname
    recurse_again $dirname $level
}

recurse_again [pwd] 0

