【问题标题】:Expect scripting basics期待脚本基础知识
【发布时间】:2012-04-23 11:11:56
【问题描述】:

我是 Expect 脚本的新手,我想知道任何可以从 Expect 脚本基础开始的链接。

  1. 命令语法
  2. 如何运行和测试脚本。

【问题讨论】:

    标签: expect


    【解决方案1】:

    获取本书Exploring Expect。 Expect 是Tcl 的扩展,所以通过Tcl tutorial

    关于如何使脚本可执行的快速教程:

    1. 您需要一个“shebang”行来让操作系统知道如何解释您的脚本
    2. 您需要授予文件可执行权限
    3. 您需要将脚本放在 $PATH 中的目录中,或者使用完整路径或相对路径调用它。
    $ cat > test.exp << END
    #!/usr/bin/expect -f
    send_user "hello world\n"
    END
    $ chmod a+x test.exp
    $ ./test.exp
    hello world
    

    当你开发和测试你的 Expect 脚本时,把

    exp_internal 1
    

    在开头。

    【讨论】:

    • 您好,您能告诉我如何运行 Expect 脚本文件吗?
    • 您好格伦,非常感谢您的支持。我可以知道需要 exp_internal 1 吗?
    • 'exp_internal 1' 行导致进一步的命令将内部诊断信息发送到 Expect 到 stderr。它本身不是调试,但它提供了一些期望处理的日志记录。
    猜你喜欢
    • 2015-11-21
    • 1970-01-01
    • 1970-01-01
    • 2014-04-16
    • 2018-05-25
    • 2014-11-28
    • 2014-02-14
    • 2023-04-10
    • 1970-01-01
    相关资源
    最近更新 更多