在Expect脚本中执行 [英] Do-while in Expect script

查看:85
本文介绍了在Expect脚本中执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下代码,并尝试执行它.但是我在执行do {"

I wrote the below code and try to execute it. But i face the "invalid command name "do" while executing 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}

请让我知道以解决此问题. 期望脚本中是否存在do-while?

Please let me know to fix this issue. Does do-while exist in Expect script?

推荐答案

简短的答案是否".

稍长的答案是:

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

完整的讨论可以在Tcl Wiki上找到.

The full discussion can be found on the Tcl wiki.

这篇关于在Expect脚本中执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆