我编写了下面的代码并尝试执行它.但我在执行do {"时遇到"无效的命令名称"do"
码:
#!/usr/bin/expect
set val 0;
set input 5;
do {
puts "\nval = $val"
set input [expr $input-1];
set val [expr $val+1];
} while {input}
Run Code Online (Sandbox Code Playgroud)
请让我知道解决这个问题.在Expect脚本中是否存在?
最简洁的答案是不.
稍长的答案是:
while true {
puts "\nval = $val"
incr val
if {[incr input -1] == 0} break
}
Run Code Online (Sandbox Code Playgroud)
完整的讨论可以在Tcl wiki上找到.