Do-while pending script

I wrote the code below and will try to execute it. But I encounter an "invalid command name" do "at runtime do {"

the code:

#!/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}

Please let me know to fix this problem. Does as long as exist in an Expect script?

+3
source share
1 answer

The short answer is no.

A slightly longer answer:

while true {
    puts "\nval = $val"
    incr val
    if {[incr input -1] == 0} break
}

Full discussion can be found on the wiki .

+5
source

All Articles